如何在加载到100%时打开新窗口?

代码如何修改,才能使加载到100%时打开一个新窗口,且只打开一个新窗口,我这代码执行后会打开无数个窗口,如何修改代码?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>进度条</title>
</head>
<head>
<style type="text/css">
#border_style {
    width:200px;
    border:1px solid #000;
    background:#CCC;
    color:#000;
}
#progress {
    display:block;
    width:0px;
    background:#CCCCFF;
}
#text {
    margin-left:30px
}
* {
    margin:0;
    padding:0;
}
</style>
<script language="javascript">

function progressL(n){
var p=document.getElementById('progress');
var text = document.getElementById("text");
p.childNodes[0].nodeValue=n+"%";
p.style.width=(n*2)+"px";
n+=1;
if(n>25){
    text.innerHTML="正在加载....";
    }
if(n>60){
    text.innerHTML="加载即将完成....";
    }
if(n>85){
    text.innerHTML="即将打开新窗口...."; 
    }
if(n>100){
    window.open('http://www.baidu.com','width=600,height=400px,top=100px,left=0px','_blank')
    n=100;
    }

setTimeout('progressL('+n+')',80);
}
</script>
</head>

<body>
<p id="border_style"><span id="progress">0%</span></p>
<br/>
<div id="text"></div>
<script language="javascript">
progressL(0);
</script>
</body>
</html>


阿尔滨必胜
浏览 1550回答 3
3回答

化龙贝

setTimeout('progressL('+n+')',80); 只会执行一次吧?
打开App,查看更多内容
随时随地看视频慕课网APP