求大神指導其中還有什么需要改進的地方
<!DOCTYPE HTML>
<html>
<head>
? ?<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ?<title>無標題文檔</title>
? ?<script>
? ? ? ?setInterval(myfunction,5000);
? ? ? ?setInterval(bb,1000);
? ? ? ?var i =6;
? ? ? ?function bb() {
? ? ? ? ? ?i--;
? ? ? ? ? ? ? ?document.getElementById("demo").innerHTML=i;
? ? ? ?}
? ? ? ?function myfunction() {
? ? ? ? ? ?window.open('http://www.xianlaiwan.cn/u/5679319/courses','_self','width=200,height=300')
? ? ? ?}
? ? ? ?function aa(){
? ? ? ? ? ?window.history.forward()
? ? ? ?}
? ?</script>
</head>
<body>
<h3>操作成功</h3>
<span id="demo">5</span>
<span id="demc">秒后回到主頁</span>
<a href="" onclick="aa()">返回</a>
</body>
</html>
2017-08-17
個人觀點:
你用了兩個計時器,一個用來-1計秒,一個用來5秒后跳轉,題目的意思應該是只用一個計時器,當計秒到0后之前 跳轉(結束計時器);而且你的計時器都是沒有清除的
2017-08-20
?<body>
? <!--先編寫好網頁布局-->
? <p>操作成功</p>
? <div>
? <span id="second"></span>
? <a>秒后回到主頁</a>
? <a href="" onclick="Go()">返回</a>
? </div>
? <script type="text/javascript"> ?
? ?var t=5;
? function oStart(){
? document.getElementById("second").innerHTML=t;
? t=t-1;
? if(t<0){
? window.location.assign("https://www.baidu.com")
? }
? setTimeout(oStart,1000)
? }
? oStart();
? function Go(){
? window.history.go(1)
? }
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?//通過window的location和history對象來控制網頁的跳轉。
?</script>?
2017-08-17
你也可以試試這個
2017-08-17
我覺得寫的挺好的了。我不是專業的前端。
<!DOCTYPE HTML>
<html>
<head>
? ?<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ?<title>無標題文檔</title>
? ?<script>
? ? ??
? ? ? ?setInterval(bb,1000);
? ? ? ?var i =5;
? ? ? ?function bb() {
? ? ? ? ? ?i--;
????????? ?document.getElementById("demo").innerHTML=i;
????????? ? if(i<=0){
????????? ? ? ? ? ? window.open('http://www.xianlaiwan.cn/u/5679319/courses','_self','width=200,height=300')
????????? ?}
? ? ? ?}
? ? ? ?function aa(){
? ? ? ? ? ?window.history.forward()
? ? ? ?}
? ?</script>
</head>
<body>
<h3>操作成功</h3>
<span id="demo">5</span>
<span id="demc">秒后回到主頁</span>
<a href="" onclick="aa()">返回</a>
</body>
</html>