Home > Web Front-end > JS Tutorial > body text

js method to close one window and open another window

一个新手
Release: 2017-10-14 09:37:57
Original
3448 people have browsed it

<!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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!