##The operating environment of this tutorial: windows7 system, javascript1 .8.5 version, DELL G3 computer.Methods to close JavaScript web pages: 1. Close the window without any prompts, the code is [Close].
How to close the javascript web page:
1. JS code to close the window without any prompt
<a href="javascript:window.opener=null;window.open('','_self');window.close();">关闭</a>
2. Close the current page (prompt under IE)
<a href="javascript:window.opener=null;window.close();">关闭</a>
3. Close the custom prompt
<script language="javascript"> function custom_close() { if (confirm("您确定要关闭本页吗?")) { window.opener = null; window.open('', '_self'); window.close() } else {} } </script> <input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" />
<body οnbefοreunlοad="return '真的要关闭此窗口吗?'">
Related free learning recommendations: javascript learning tutorial
The above is the detailed content of How to turn off javascript web pages. For more information, please follow other related articles on the PHP Chinese website!