為什么用不起window.open(url)方法,到了0的時候就不會跳轉
為什么用不起window.open(url)方法,到了0的時候就不會跳轉
```javascript
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <form>
? ? ? ?<p>操作成功</p>
? ? ? ?<h id="h">5</h>
? ? ? ?<button onclick="gotoLastPage()">返回</button>
? </form>
??
?
? <script type="text/javascript">??
? ? var i = 5;?
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?function setTime(){
? ? ? ? document.getElementById("h").innerHTML = i;?
? ? ? ? i= i-1;
? ? ? ? if (i==0){
window.location.assign("http://www.xianlaiwan.cn");
? ? ? ? }
? ?}
? ?var i = setInterval("setTime()", 1000);
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function gotoBaidu() {
? ? ? ?window.open("https://baidu.com", "_black");
? ?}
? ?
? ?function gotoLastPage() {
? ? ? ?window.history.back();
? ?}
? ?
?</script>?
```
2018-07-27
var i = setInterval("setTime()", 1000); ? ? --> ? ? ? ? ? setInterval(setTime, 1000);