【发布时间】:2020-07-14 02:35:32
【问题描述】:
<p id="countdown"></p>
<div id="startButtons">
<button onclick="sample()" id="gameStart" class="gameStart">LETS GO!</button>
<script>
var timeleft = 90;
window.onload = timedText;
function sample() {
document.getElementById('paragraph').innerHTML = "<style>.paragraph(visibility:collapse);";
document.getElementById('gameStart').innerHTML = "<style>.gameStart(visibility:collapse);";
var downloadTimer = setInterval(function
function1() {
document.getElementById("countdown").innerHTML = timeleft + " " + "seconds left";
timeleft -= 1;
if (timeleft <= 0) {
clearInterval(downloadTimer);
document.getElementById("countdown").innerHTML = "The time has ended!";
window.open("index2.1.html");
}
}, 1000);
console.log(countdown)
}
</script>
我在做这个文字游戏,当我重新加载页面时,我真的不知道如何启动计时器,我希望计时器自己启动,所以如果我在主页上单击 Enter 并到达此页面计时器应该自行启动......,当计时器完成时,另一个窗口应该打开,即 2.1 index.html 谢谢
【问题讨论】:
标签: javascript java html css timer