我寫了這個簡單的腳本,但我評論它,並試圖只爲window.alert,什麼都沒有發生。它只是不會工作,簡單的窗口提醒,所以其他代碼也不會工作。它看起來像JavaScript沒有加載到頁面中。任何想法如何解決這個問題? 這裏是我的代碼:JavaScript簡單的腳本將不會加載
<!doctype html>
<html>
<head>
<title>Vesanje</title>
</head>
<body>
<div>
trenutna rec: <span id="trenutna_rec"></span>
<br>
broj pokusaja: <span id="br_pokusaja"></span>
<br>
trenutno slovo: <input type="text" id="slovo">
<br>
koriscena slova: <input type="text" id="koriscena_slova" readonly>
<br>
<br>
<input type="button" value="zameni pojavljivanja" id="dugme">
</div>
<canvas id="platno" height="" width="">
</canvas>
<script type='text/javascript'>
window.alert("kliks");
/*
window.rec="javascript";
window.alert("test");
var trenutna_rec = document.querySelector("#trenutna_rec");
var trenutna_rec_niska = new Array();
for(let i=0; i<window.rec.length; i++){
trenutna_rec_niska[i]= "_ ";
}
trenutna_rec.textContent = trenutna_rec_niska.join("");
var br_pokusaja = document.querySelector("#br_pokusaja");
var br_pokusaja_vrednost=0;
br_pokusaja.textContent=0;
var tekuce_slovo = document.querySelector("#slovo");
var koriscena_slova = document.querySelector("#koriscena_slova");
var koriscena_slova_niz = new Array();
var dugme = document.querySelector("#dugme");
dugme.onclick=function(){
//procita tekuce slovo
var ts=tekuce_slovo.value;
var zamene=0;
//spreciti unos unetih slova
if(koriscena_slova_niz.indexOf(ts)!=-1){
return;
tekuce_slovo.value="";
}
//provelrimo da li se slovo nalazi u reci
for(let i=0; i<window.rec.length; i++){
if(window.rez[i]==ts){
trenutna_rec_niska[i]=ts;
zamene++;
}
}
//izvrsimo zamenu ako je potrebno
//ispisati novu tekucu rec
trenutna_rec.textContent = trenutna_rec_niska.join("");
//ispisati novi br pokusaja
br_pokusaja_vrednost++;
br_pokusaja.textContent = br_pokusaja_vrednost;
//dopisemo korisceno slovo
koriscena_slova_niz.push(ts);
koriscena_slova.textContent=koriscena_slova_niz.join("");
tekuce_slovo.value = "";
}/*
</script>
</body>
</html>
作品等您不關閉您的評論'/ *。 .. * /'而不是'/ * .../*' – Justinas