<!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() { //創(chuàng)建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(); //如果是單個數(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)建要
相信看了這些案例你已經(jīng)掌握了方法,更多精彩請關(guān)注Gxl網(wǎng)其它相關(guān)文章!
相關(guān)閱讀:
h5的組織內(nèi)容如何使用
H5怎樣做出日歷校驗(yàn)功能
H5怎樣調(diào)用相機(jī)拍照并壓縮圖片
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com