完美運(yùn)行帶思路
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網(wǎng)頁(yè)布局-->
? <h3>操作成功</h3>
? <p><span id="sqtimen"></span>秒后回到首頁(yè)<a href="#" onclick="goback()">返回</a></p>
?
?
?
? <script type="text/javascript"> ?
var num=5;
?function change(){
?? ?
?? ?if(num==0){
?? ?clearTimeout(i);
?? ? location.assign("http://idcbgp.cn");
?? ?}
?? ?else{
?? ?document.getElementById("sqtimen").innerText=num;
?? ?num=num-1;
?? ?var i=setTimeout(change,1000);
?? ?}
?
?? //獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
?? //通過window的location和history對(duì)象來控制網(wǎng)頁(yè)的跳轉(zhuǎn)。
?? function goback(){
?? window.history.back();
?? }
}? ?
??? change();
?</script>
</body>
</html>
利用H3標(biāo)簽輸出
利用p標(biāo)簽里面嵌套span標(biāo)簽并設(shè)置一個(gè)id用于接收數(shù)據(jù),“秒后回到首頁(yè)”繼續(xù)嵌套用a標(biāo)簽屬性里加入onclick事件,
設(shè)置變量 var num=5;
創(chuàng)建change()方法,
if判斷(num==0)停止計(jì)時(shí)i,打開網(wǎng)站
else:用document.getElementById("").innerText=num;num的值賦給<span>idName,
num--;
創(chuàng)建時(shí)間計(jì)時(shí)器方法change每秒運(yùn)行一次當(dāng)num等于0滿足條件,停止計(jì)時(shí)操作打開網(wǎng)站。
change();調(diào)用方法
2019-11-14
666? 受教了
2019-11-12
nice? nice
2019-11-12
不錯(cuò),學(xué)習(xí)了
2019-11-07
學(xué)習(xí)學(xué)習(xí)
2019-10-30
寫得好