Home >Web Front-end >JS Tutorial >How to close javascript window
Methods for closing JavaScript windows: 1. JS automatically closes the window at a scheduled time; 2. Clicking on the link does not prompt JS to close the window; 3. The window does not prompt the JS code to automatically close.
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
How to close the javascript window:
The first one: JS automatically closes the window at a scheduled time
<script language="javascript"> <!-- function closewin() { self.opener=null; self.close(); } function clock() { i=i-1 document.title="本窗口将在" + i + "秒后自动关闭!"; if(i>0)setTimeout("clock();",1000); else closewin(); } var i=10 clock(); //--> </script>
The second type: JS code that closes the window without prompt when clicking on the link
<a href="javascript:window.close()" >关闭窗口</a>
The third type: JS code that automatically closes the window without prompt
<script language=javascript> <!-- this.window.opener = null; window.close(); //--> </script>
Related free learning recommendations: javascript video tutorial
The above is the detailed content of How to close javascript window. For more information, please follow other related articles on the PHP Chinese website!