0
0

More than 5 years have passed since last update.

JavaScript 自動排程 By 彭彭 22

Posted at
8. 自動排程 功能

WS000018.JPG


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"></meta>
    <title>自動排程 Schedule</title>
    <script type="text/javascript">
    //alert("hello");
    // 一秒鐘之後 排程動作的基本
    // setTimeout only執行一次countdown 倒數
    // setInterval 每秒鐘執行一次countdown 倒數
    var timer;
    function init(){
        timer = document.getElementById("timer");
        //window.setInterval(countdown,1000);
        window.setInterval(countdown,1000);
    }
    function countdown(){
        timer.innerHTML = timer.innerHTML-1;
        if(timer.innerHTML > 0){
        //window.setTimeout(countdown,1000);
        }else{
        document.location="http://www.sina.com";
        }
    }
    </script>
</head>
<body onload = "init();">
    <span id = "timer">3</span>
</body>
</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0