文法エラーが表示されます。128行目あたりの</script>、160行目あたりのinit();、168行目あたりのranking();が文法エラーのようなのですが、どこがおかしいのか理解しかねました。どのうにすればよいのでしょうか。
もぐらたたきのhtmlを作っています。
html
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"/> <title>もぐらたたき</title> <script type="text/javascript" src="zepto.min.js"></script> <script type="text/javascript"> var imgs = document.getElementsByName("im"); var st, en, score, tid = null; var mole = new Array(16); var a1 = new Array(4); var a1_cnt = 0; for(i = 0; i < 4; i++){ a1[i] = new Audio("mogura.mp3"); } function init(){ score = 0; document.c0.src = "/~h128kamo/public_html/webpro/" + parseInt(score / 100) + ".j\ pg"; document.c1.src = "/~h128kamo/public_html/webpro/" + (parseInt(score / 10) % 10)\ + ".jpg"; document.c2.src = "/~h128kamo/public_html/webpro/" + (score % 10) + ".jpg"; seconds = 0; document.s0.src = "/~h128kamo/public_html/webpro/" + parseInt(seconds / 100) + "\ .jpg"; document.s1.src = "/~h128kamo/public_html/webpro/" + (parseInt(seconds / 10) % 1\ 0) + ".jpg"; document.s2.src = "/~h128kamo/public_html/webpro/" + (seconds % 10) + ".jpg"; for(i = 0; i < 16; i++){ var x = Math.random(); if( x < 0.3 ){ imgs[i].src = 'mogura.jpg'; } else if( 0.3 < x && x < 0.6 ){ imgs[i].src = 'doara.jpg'; } else{ imgs[i].src = 'white.jpg'; } } } function game_start(){ init(); st = new Date().getTime(); update(); time(); } function time(){ if( tid == null ) return; en = new Date().getTime(); seconds = (en - st) / 1000; document.s0.src = "/~h128kamo/public_html/webpro/" + parseInt(seconds / 100) + "\ .jpg"; document.s1.src = "/~h128kamo/public_html/webpro/" + (parseInt(seconds / 10) % 1\ 0) + ".jpg"; document.s2.src = "/~h128kamo/public_html/webpro/" + (seconds % 10) + ".jpg"; setTimeout("time()", 500); function update(){ for(i = 0; i < 16; i++){ var x = Math.random(); if( x < 0.3 ){ imgs[i].src = 'mogura.jpg'; } else if( 0.3 < x && x < 0.6 ){ imgs[i].src = 'doara.jpg'; } else{ imgs[i].src = 'white.jpg'; } } tid = setTimeout("update()", 500); } function whack(i){ if( tid == null ) return; if( imgs[i].src.slice(-10) == 'mogura.jpg' ){ a1[a1_cnt++].play(); a1_cnt &= 3; imgs[i].src = 'white.jpg' ; score++; if( score >= 30 ){ en = new Date().getTime(); clearTimeout(tid); tid = null; time = (en - st) / 1000; if( !document.cookie ){ name = prompt("あなたのタイムは" + time + "秒でした\n あなたのお名前を入れ\ てください",""); document.cookie = "name=" + name + "; max-age=86400"; document.getElementById("name").value = name; }else{ alert(document.getElementById("name").value + "さんのタイムは" + time + "\\ 秒でした。"); } $.get("6.php?name=" + encodeURI(name) + "&time=" + time, function(){ ranking(); }); } } else if( imgs[i].src.slice(-10) == 'doara.jpg' ){ a1[a1_cnt++].play(); a1_cnt &= 3; imgs[i].src = 'doara.jpg' ; score--; score--; } else{ a1[a1_cnt++].play(); a1_cnt &= 3; imgs[i].src = 'white.jpg' ; score--; } document.c0.src = "/~h128kamo/public_html/webpro/" + parseInt(score / 100) + ".j\ pg"; document.c1.src = "/~h128kamo/public_html/webpro/" + (parseInt(score / 10) % 10)\ + ".jpg"; document.c2.src = "/~h128kamo/public_html/webpro/" + (score % 10) + ".jpg"; }function ranking(){ _d = new Date().getTime(); $.get("6ranking.php?_d=" + _d, function(data){ var a = data.split("\n"); var table = "<table border=1 cellspacing=0 cellpadding=2>"; table += "<tr><td>順位</td><td>時間</td><td>名前<.td><td>日時</td></tr>"; for(i=0;i<a.length-1;i++){ var b = a[i].split(","); table += "<tr><td>" + (i+1) + "</td><td>" + b[2] + "</td><td>" + b[1] + "</t\ d><td>" + b[0] + "</td></tr>"; } table += "</table>"; document.getElemantById("ranking").innerHTML = table; }); } </script> </head> <body align="center" bgcolor="antiquewhite"> <h1><font color="brown">もぐらたたき</font></h1> <h3>~マニュアル~</h3> <p>もぐらを30匹たたくまでの時間を競うゲームです。</p> <p>もぐらをたたくと1点加算されます。</p> <p>もぐらのいないところをたたくと1点減点されます。</p> <hr size="3" color="brown"><br> 名前 : <input type="text" id="name" onChange='document.cookie = "name=" +this.valu\ e + "; max-age=86400"'><br><br> <input type="button" onClick="game_start()" value="ゲーム開始"><br><br> 得点 : <span id="score"></span> <img name="c0" width="10" height="10"><img name="c1" width="10" height="10"><img n\ ame="c2" width="10" height="10"> <br> <br> タイム : <img name="s0" width="10" height="10"><img name="s1" width="10" height="10"><img n\ ame="s2" width="10" height="10"> <br> <br> <div style="line-height:0"> <img name="im" onClick="whack(0)" width="100" height="100"><img name="im" onClick=\ "whack(1)" width="100" height="100"><img name="im" onClick="whack(2)" width="100" \ height="100"><img name="im" onClick="whack(3)" width="100" height="100"><br> <img name="im" onClick="whack(4)" width="100" height="100"><img name="im" onClick=\ "whack(5)" width="100" height="100"><img name="im" onClick="whack(6)" width="100" \ height="100"><img name="im" onClick="whack(7)" width="100" height="100"><br> <img name="im" onClick="whack(8)" width="100" height="100"><img name="im" onClick=\ "whack(9)" width="100" height="100"><img name="im" onClick="whack(10)" width="100"\ height="100"><img name="im" onClick="whack(11)" width="100" height="100"><br> <img name="im" onClick="whack(12)" width="100" height="100"><img name="im" onClick\ ="whack(13)" width="100" height="100"><img name="im" onClick="whack(14)" width="10\ 0" height="100"><img name="im" onClick="whack(15)" width="100" height="100"><br> </div> <script type="text/javascript"> var name = document.cookie.replace(/(?:(?:^|.*;\s*)name\s*\=\s*([^;]*).*$)|^.*$/, \ "$1"); if( name ){ document.getElementById("name").value = name; } </script> <br><br><br> <script type="text/javascript"> init(); </script> <br> <b>ランキング</b><br> <div id="ranking"></div> <script type="text/javascript"> ranking(); </script> </body> </html>
まだ回答がついていません
会員登録して回答してみよう