The code is as follows:
//指定时间之后跳转 <script language="javascript"> function go( ) {//定义函数 window.location="main.html";//页面跳转 } window.setTimeout("go()",1000);//1秒后执行函数go </script> //指定时间之后自动关闭 <script type="text/javascript"> function closeMyWindow() { window.setTimeout("window.close()", 1000); } </script> <body> <p> <!--Chrome IE有效,FireFox无效--> <input type="button" value="return closeMyWindow()" onclick="return closeMyWindow()" /> <br /> <!--Chrome IE有效,FireFox无效--> <input type="button" value="onclick='closeMyWindow()'" onclick="closeMyWindow()" /> <br /> <!--IE有效,FireFox无效--> <a href="#" onclick="closeMyWindow()">'closeMyWindow()'</a> <br/> <!--Chrome IE有效,FireFox无效--> <a href="#" onclick="window.close()">'window.close()'</a> <br/> </p> </body>
Related articles:
Click the return button to close the current page and window in WeChat, Alipay and Baidu Wallet
JS summary of several ways to close the current page (window)
Open a new window and close the current page without popping up the closing prompt js code