Simple version of Mine Clearance

Source: Internet
Author: User
<SCRIPT type = "text/JavaScript"> alert ('click it: the square turns red, which is the default minefield. Click two: Show number or click !! '); Var TM = 0, fm = 0; function $ (x) {return (document. getelementbyid (x);} function ST () {var show = $ ("show"); For (x = 1; x <11; X ++) {for (y = 1; y <11; y ++) {var nD = document. createelement ("Div"); nd. classname = "A-1"; nd. X = x; nd. y = y; nd. id = string (x) + Y; RND = math. ceil (math. random () * 4); If (RND = 1) {nd. W = "*"; TM ++;} else {nd. W = 0; FM ++;} Nd. status = 0; nd. innerhtml = "<a href = '# 'onclick = 'loc (this)'> </a>"; show. appendchild (ND) ;}} function LOC (O BJ) {var JS = 0; If (obj. parentnode. status = 0) {obj. style. background = "# ff0000"; obj. parentnode. status = 1;} else if (obj. parentnode. status = 1) {obj. parentnode. status = 2obj. style. background = "# cccccc"; if (obj. parentnode. W = "*") {alert ('you have stepped on the zhonglei area. failed! '); Obj. innerhtml = obj. parentnode. w;} else {x = obj. parentnode. x; y = obj. parentnode. y; If (x = 1) {If (y = 1) {if ($ ("12 "). W = "*") JS ++; if ($ ("21 "). W = "*") JS ++; if ($ ("21 "). W = "*") JS ++;} else if (y = 10) {if ($ ("19 "). W = "*") JS ++; if ($ ("29 "). W = "*") JS ++; if ($ ("210 "). W = "*") JS ++;} else {if ($ ("1" + (Y-1 )). W = "*") JS ++; if ($ ("1" + (Y + 1 )). W = "*") JS ++; if ($ ("2" + (Y-1 )). W = "*") JS ++; if ($ ("2" + Y ). W = "*") JS ++; if ($ ("2" + (Y + 1 )). W = "*") JS ++;} else I F (x = 10) {If (y = 1) {'if ($ ("102 "). W = "*") JS ++; if ($ ("91 "). W = "*") JS ++; if ($ ("92 "). W = "*") JS ++;} else if (y = 10) {if ($ ("99 "). W = "*") JS ++; if ($ ("910 "). W = "*") JS ++; if ($ ("109 "). W = "*") JS ++;} else {if ($ ("10" + (Y-1 )). W = "*") JS ++; if ($ ("10" + (Y + 1 )). W = "*") JS ++; if ($ ("9" + (Y-1 )). W = "*") JS ++; if ($ ("9" + Y ). W = "*") JS ++; if ($ ("9" + (Y + 1 )). W = "*") JS ++;} else {If (y = 1) {if ($ (x-1) + "1 "). W = "*") JS ++; if ($ (x + 1) + "1 "). W = "*") JS ++; if ($ (x-1) + "2 "). W = "*") JS ++; if ($ (x + "2 "). W = "*") JS ++; if ($ (x + 1) + "2 "). W = "*") JS ++;} else if (y = 10) {if ($ (x-1) + "10 "). W = "*") JS ++; if ($ (x + 1) + "10 "). W = "*") JS ++; if ($ (x-1) + "9 "). W = "*") JS ++; if ($ (x + "9 "). W = "*") JS ++; if ($ (x + 1) + "9 "). W = "*") JS ++;} else {if ($ (string (x-1) + (Y-1 )). W = "*") JS ++; if ($ (string (x-1) + Y ). W = "*") JS ++; if ($ (string (x-1) + (Y + 1 )). W = "*") JS ++; if ($ (string (x) + (Y-1 )). W = "*") JS ++; if ($ (string (x) + (Y + 1 )). W = "*") JS + +; If ($ (string (x + 1) + (Y-1 )). W = "*") JS ++; if ($ (string (x + 1) + Y ). W = "*") JS ++; if ($ (string (x + 1) + (Y + 1 )). W = "*") JS ++;} obj. innerhtml = JS ;}} else {alert ('Sorry, opening the card is not allowed to be opened again! ') ;}}</SCRIPT> <style>. a-1 A {width: 10%; Height: 13px; padding: 20px; display: inline; float: Left; border-bottom: #666666 3px solid; border-right: #666666 3px solid; border-left: 3px # ffffff solid; border-top: 3px # ffffff solid; Background-color: # cccccc; color: #000000; font-family: ""; font-size: 13px ;}. a-1 A: hover {width: 10%; Height: 13px; padding: 20px; display: inline; float: Left; color: #000000; font-family: ""; font-size: 13px; border-bottom: # ffffff 3px solid; border-Right: # ffffff 3px solid; border-left: 3px #666666 solid; border-top: 3px #666666 solid ;}</style> <body bgcolor = "#669900" onLoad = "ST ()"> <Div style = "margin: 0 auto; width: 600px; "> <Div id =" show "style =" width: 615px; Height: 590px; float: Left; Border: 2px #000000 solid; display: inline; "> </div> </body>

Mine clearance in 2 hours

Not as powerful as windows

The Code is also relatively simple. New users like me can use it for fun.

This is the code compatible with IE

People are too lazy to write compatibility things ....

Leave a message to my blog if you have any questions.

You are welcome to correct and improve your skills ....

Let's encourage me to learn about JS together !!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.