小编Dae*_*rik的帖子

javascript setTimeout()不起作用

嗨我正在尝试在javascript中使用函数setTimeout(),除非它不起作用.提前感谢任何可以提供帮助的人.

<!DOCTPYE html>
<html>
<head>
    <script>
        var button = document.getElementById("reactionTester");
        var start  = document.getElementById("start");

        function init() {
            var startInterval/*in milliseconds*/ = Math.floor(Math.random() * 30) * 1000;
            setTimeout(startTimer(), startInterval);
        }

        function startTimer() {
            document.write("hey");
        }
    </script>
</head>
<body>
<form id="form">
    <input type="button id=" reactionTester" onclick="stopTimer()">
    <input type="button" value="start" id="start" onclick="init()">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript

41
推荐指数
4
解决办法
8万
查看次数

标签 统计

javascript ×1