差一個5 4 3 2 1 那個計時器死活輸出不出來,救命
<!DOCTYPE HTML>
<html>
<head>
? ?<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ?<title>無標(biāo)題文檔</title>
? ?<script>
? ? ? ?setInterval(myfunction,5000);
? ? ? ?setInterval(bb,1000);
? ? ? ?function bb() {
? ? ? ? ? ?for(var i=5;i>=1;i--){
? ? ? ? ? ? ? ?document.getElementById("demo").innerHTML=i;
? ? ? ? ? ?}
? ? ? ?}
? ? ? ?function myfunction() {
? ? ? ? ? ?window.open('http://idcbgp.cn/u/5679319/courses','_self','width=200,height=300')
? ? ? ?}
? ? ? ?function aa(){
? ? ? ? ? ?window.history.forward()
? ? ? ?}
? ?</script>
</head>
<body>
<h3>操作成功</h3>
<span id="demo"></span>
<span id="demc">秒后回到主頁</span>
<a href="" onclick="aa()">返回</a>
</body>
</html>
2017-08-16
?function bb() {
? ? ? ? ? ?for(var i=5;i>=1;i--){
? ? ? ? ? ? ? ?document.getElementById("demo").innerHTML=i;
? ? ? ? ? ?}
? ? ? ?}
這個沒意義。運算速度很快的。i=5 變到0基本看不到。
可以換成
?var num=5;
? ? var i=setTimeout("bb()",1000);
? ?function bb(){
?document.getElementById('demo').innerHTML=num;
?if(num==0){
? window.history.go(-1);
?}
?else{
? ? num=num-1;
? ? ?setTimeout("bb()",1000);
?}