Home Web Front-end HTML Tutorial HTML implements the ticket grabbing function (set time to open the ticket grabbing page)

HTML implements the ticket grabbing function (set time to open the ticket grabbing page)

Jan 16, 2018 am 09:28 AM
html Open

Today I will introduce to you a very useful function, HTML implements the ticket grabbing function, and also provides you with a solution. Friends who need it can save notes.

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <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>
Copy after login

I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to use h5’s organizational content

How to create a calendar verification function in H5

How to call the camera to take pictures and compress pictures in H5

The above is the detailed content of HTML implements the ticket grabbing function (set time to open the ticket grabbing page). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles