HTML完成双11抢劵(设置時间开启抢券的网页页面

空话很少说了,立即给大伙儿贴编码了,实际编码以下所示:
 

 

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf⑻" />
    <title></title>
    <style type="text/css">
        #result{
            width:500px;
            border:1px solid #CCCCCC;
            background:#FFFFCC;
            margin:50px auto;
            font-size:24px;
            color:#FF0000;
            padding:20px;
        }
    </style>
    <script type="text/javascript">
        window.onload = function () {
            showTime();
            var start = document.getElementById("start");
            start.onclick=function () {
                var path = document.getElementById("path").value;
                var time1 = document.getElementById("time1").value;
                var time2 = document.getElementById("time2").value;
                var time3 = document.getElementById("time3").value;
                start.value = "等候开启抢单网页页面";             
                setInterval(function () {
                    var date = new Date();
                     var hour = date.getHours();
                     var minute = date.getMinutes();
                     var second = date.getSeconds();
                    if (hour == time1 && minute == time2 && second == time3) {
                        window.open(path);
                    }
                }, 100);
            };       
        }
        function showTime()
        {
             //建立Date目标
             var today = new Date();
             //各自取下年、月、日、时、分、秒
             var year = today.getFullYear();
             var month = today.getMonth()+1;
             var day = today.getDate();
             var hours = today.getHours();
             var minutes = today.getMinutes();
             var seconds = today.getSeconds();
             //假如是单独数,则前面补0
             month  = month<10  ? "0"+month : month;
             day  = day <10  ? "0"+day : day;
             hours  = hours<10  ? "0"+hours : hours;
             minutes = minutes<10 ? "0"+minutes : minutes;
             seconds = seconds<10 ? "0"+seconds : seconds;
             //搭建要輸出的标识符串
             var str = year+"年"+month+"月"+day+"日 "+hours+":"+minutes+":"+seconds;             
             //获得id=result的目标
             var obj = document.getElementById("result");
             //将str的內容写入到id=result的<div>中去
             obj.innerHTML = str;
             //延时器
             window.setTimeout("showTime()",1000);
        }
    </script>
</head>
<body>
    <div>
        <h2>1,同歩电脑上時间和北京時间</h2>
        <h2>2,设定path详细地址为必须抢券的详细地址和抢券時间</h2>
        <!--<h3>抢券详细地址</h3><input type="text" id=path />-->
        <h3>抢券详细地址(留意不必漏掉http://或https://)</h3> <!--<textarea id="path" style="width:200px;height:80px;"></textarea>-->
        <input  type="url" id="path" style="width:auto"/>
        <h3>抢券時间</h3>
        <input type="text" id=time1 />时<input type="text" id=time2 />分
        <input type="text" id=time3 />秒
        <h2>3,点一下等候,随后去点一下抢券</h2>
        <input  type="button" id="start" value="刚开始"/><div id="result"></div>
    </div>
</body>
</html>

总结

以上所述是网编给大伙儿详细介绍的HTML完成双11抢劵(设置時间开启抢券的网页页面),期待对大伙儿有一定的协助,假如大伙儿有任何疑惑请给我留言,网编会立即回应大伙儿的。在此也十分谢谢大伙儿对脚本制作之家网站的适用!