8-17編程練習(xí) 做一個(gè)倒計(jì)時(shí)返回的例程
標(biāo)簽:
JavaScript
一开始是因为浏览器自动屏蔽弹窗,导致调试了好久,后来是因为location.assig(),拼写出错,导致浪费了一些时间,总的来说收获很大。
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1>
<span id = "num">5 </span>
<span id = "dao">秒后 返回主页 </span>
<a href = "javascript:back()">返回 </a>
<script type="text/javascript">
var i =document.getElementById("num").innerHTML;
//获取显示秒数的元素,通过定时器来更改秒数。
function count(){
//i--;
document.getElementById("num").innerHTML = --i;
if(i==0){
location.assign("idcbgp.cn");
}
//location.assgin("www.baidu.com");
}
var j =setInterval("count()",2000);
//通过window的location和history对象来控制网页的跳转。
function back(){
window.history.back();
}
</script>
</body>
</html>
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦