Home  >  Article  >  Web Front-end  >  js method to close one window and open another window

js method to close one window and open another window

一个新手
一个新手Original
2017-10-14 09:37:573414browse

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
    //   第一种方法,在body里的onunload事件中调用
//
 
function openWin(){
//
 
window.open(&#39;https://www.baidu.com&#39;);
//
 
}
//
 
//   第二种方法,跟第一种差不多
function closewin(){
window.opener=null;
window.open(&#39;https://www.baidu.com&#39;);
window.close();
}
//   第三种,在多少秒之后关闭窗口并打开新的页面
function clock(i) {   //  i为传入几秒
var timer = setInterval(function(){
if(i>0){
document.title= i + "秒后自动关闭本窗口!";
}else{
clearInterval(timer);
closewin();
}
i=i-1;
},1000);
}   
//-->
</script>
</head>
<!--<body onunload="openWin()">-->
<body>
</body>
</html>

The above is the detailed content of js method to close one window and open another window. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn