<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> // 第一种方法,在body里的onunload事件中调用 // function openWin(){ // window.open('https://www.baidu.com'); // } // // 第二种方法,跟第一种差不多 function closewin(){ window.opener=null; window.open('https://www.baidu.com'); 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!