為什么5秒之后沒有反應(yīng)
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h3>操作成功</h3>
? <span id="second">5</span><span>秒后回到主頁</span>
? <a href="javascript:back()">返回</a>
?
? <script type="text/javascript">??
?var num=document.getElementById("second").innerHTML;
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
? ?function count()
? ?{
? ? ? ?num--;
? ? ? ?document.getElementById("second").innerHTML=num;
? ? ? ?if (num==0)
? ? ? ?{
? ? ? ? ? ?location.assign("idcbgp.cn");
? ? ? ?}
? ?}
? ? setInterval(count,1000);
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?function back()
? ?{
? ? ? window.history.back();
? ?}
?</script>?
</body>
</html>
2018-11-29
我的代碼:
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <p>
? ? ? <h4>操作成功</h4>
? </p>
??
? <form>
? ? ? <span id="txt">5</span>
? ? ? 秒后返回主頁
? ? ? <a href="javascript:goBack()" >返回</a>
? </form>
?
? <script type="text/javascript">??
? ? ?var num=5;
? ? ?function getTime() {
? ? ? ? ?document.getElementById("txt").innerHTML=num;
? ? ? ? ?num--;
? ? ? ? ?
? ? ? ? ?if (num == 0) {
? ? ? ? ? ? ?window.location.assign("http://idcbgp.cn");
? ? ? ? ?}
? ? ?}
? ? ?
? ? ?function goBack() {
? ? ? ? ?//window.history.go(-1); //返回方式2
? ? ? ? ?//window.location.assign("http://idcbgp.cn"); // 方式3:加載新頁面
? ? ? ? ?window.history.back();
? ? ?}
? ? var t = setInterval("getTime()",1000);
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?
?</script>?
</body>
</html>
2018-11-02
這個建議你可以在電腦上打開一個記事本,將代碼復(fù)制粘貼到記事本,然后將這個記事本文件保存為后綴名為.html,比如說改為hahaha.html最后再打開這個文件就可以了。再建議可以將代碼中的慕課網(wǎng)網(wǎng)址換成一下別的網(wǎng)址,比如說騰訊啊、百度啊,要不然也會有些問題,如果都這樣改了,相信你的問題應(yīng)該都會沒問題了。
2018-11-01
換外部編寫器 代碼是沒有問題的
比如Hbuilder,idear,webStrom...