html完成雙11搶劵以及設(shè)定時(shí)間打開(kāi)搶券頁(yè)面的案例
發(fā)表時(shí)間:2024-05-10 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]廢話不多說(shuō)了,直接給大家貼代碼了,具體代碼如下所示:<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta ch...
廢話不多說(shuō)了,直接給大家貼代碼了,具體代碼如下所示:
<!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 = "等待打開(kāi)搶單頁(yè)面";
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()
{
//創(chuàng)建Date對(duì)象
var today = new Date();
//分別取出年、月、日、時(shí)、分、秒
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();
//如果是單個(gè)數(shù),則前面補(bǔ)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;
//構(gòu)建要輸出的字符串
var str = year+"年"+month+"月"+day+"日 "+hours+":"+minutes+":"+seconds;
//獲取id=result的對(duì)象
var obj = document.getElementById("result");
//將str的內(nèi)容寫(xiě)入到id=result的<p>中去
obj.innerHTML = str;
//延時(shí)器
window.setTimeout("showTime()",1000);
}
</script>
</head>
<body>
<p>
<h2>1,同步電腦時(shí)間和北京時(shí)間</h2>
<h2>2,設(shè)置path地址為需要搶券的地址和搶券時(shí)間</h2>
<!--<h3>搶券地址</h3><input type="text" id=path />-->
<h3>搶券地址(注意不要漏掉http://或者h(yuǎn)ttps://)</h3> <!--<textarea id="path" style="width:200px;height:80px;"></textarea>-->
<input type="url" id="path" style="width:auto"/>
<h3>搶券時(shí)間</h3>
<input type="text" id=time1 />時(shí)<input type="text" id=time2 />分
<input type="text" id=time3 />秒
<h2>3,點(diǎn)擊等待,然后去點(diǎn)擊搶券</h2>
<input type="button" id="start" value="開(kāi)始"/><p id="result"></p>
</p>
</body>
</html>
以上就是html實(shí)現(xiàn)雙11搶劵以及設(shè)定時(shí)間打開(kāi)搶券頁(yè)面的實(shí)例的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
網(wǎng)站建設(shè)是一個(gè)廣義的術(shù)語(yǔ),涵蓋了許多不同的技能和學(xué)科中所使用的生產(chǎn)和維護(hù)的網(wǎng)站。