大神們看看那得問題啊,實(shí)在是找不到問題出在哪了,這個(gè)5不動(dòng)啊。。。
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
<h1>操作成功</h1>
<span id="second">5</span>
<span>秒后回到主頁</span>
<a href="http://idcbgp.cn/">返回</a>
? <script type="text/javascript"> ?
??? var i=getElementById("second").innerHTML;
?? //獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
???? function time()
???? {
???????? i--;
???????? document.getElementById("second").innerHTML=i;
???????? if(i==0){
??????????? location.assign("http://idcbgp.cn");
???????? }
???????? }
???????? setInterval("time()",1000);
?? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
????? function his(){
???????? window.history.back();
????? ?
????? }
?</script>
</body>
</html>
2016-11-18
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
??? <title></title>
??? <script type="text/javascript">
??????? var i = 5;
??????? function time() {
??????????? document.getElementById("count").value = i;
??????????? i = i - 1;
??????????? var x;
??????????? if (i>=0) {
???????????????? x = setTimeout("time()", 1000);
??????????? } else {
??????????????? clearInterval(x);
??????????? }
???????????
??????? }
??????? setTimeout("time()", 1000);
??? </script>
</head>
<body>
??? <input id="count" type="text"/>
</body>
</html>
2016-11-18
你給i賦值時(shí)少寫了document. ?
2016-11-18
你不應(yīng)該這樣寫啊