私はクイズを持っています。最後のページを読み込むと100%が得られたら、「あなたは100%得ました!」と警告します。 すべての要素が読み込まれた後の警告
var chanceoflive1 = parseInt(localStorage.getItem("chanceoflive1"));
var chanceoflive2 = parseInt(localStorage.getItem("chanceoflive2"));
var chanceoflive3 = parseInt(localStorage.getItem("chanceoflive3"));
var chanceoflive4 = parseInt(localStorage.getItem("chanceoflive4"));
var chanceoflive7 = parseInt(localStorage.getItem("chanceoflive7"));
var chanceoflivefinal = (chanceoflive1||0) + (chanceoflive2||0) + (chanceoflive3||0) + (chanceoflive4||0) + (chanceoflive7||0);
var chanceoflivepercent = chanceoflivefinal * 4;
function startup(){
if (chanceoflivefinal == 25) {
alert("You Got 100%!");
}
}
<body onload="startup">
<center>
<h2 class="text">Final Results</h2>
<p id="print" class="text"></p>
<p id="print2" class="text"></p>
<img src="qrcode.jpg" height="300" length="300">
<br>
<div class="wrapper">
<a href="index.html">
<button align=center onclick="handleClick()" id="button">
<canvas width="200" height="50" id="canvas" align=center></canvas>
<span class="text" id="submit">Retry</span>
</button>
</a>
</div>
</center>
</body>
がどのように私はこの問題を解決することができます。が、これは私のコードでのバックグラウンドロードの前でロードしますか?
'onload =" startup() "'を呼び出す関数の後に '()'を入れる必要があります。 – Barmar