Home > Web Front-end > JS Tutorial > How to turn off javascript web pages

How to turn off javascript web pages

coldplay.xixi
Release: 2021-03-30 11:52:52
Original
2748 people have browsed it

Methods to close JavaScript web pages: 1. Close the window without any prompts, the code is [Close].

How to turn off javascript web pages

##The operating environment of this tutorial: windows7 system, javascript1 .8.5 version, DELL G3 computer.

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(&#39;&#39;,&#39;_self&#39;);window.close();">关闭</a>
Copy after login

2. Close the current page (prompt under IE)

<a href="javascript:window.opener=null;window.close();">关闭</a>
Copy after login

3. Close the custom prompt

<script language="javascript"> 
function custom_close() { 
if (confirm("您确定要关闭本页吗?")) { 
window.opener = null; 
window.open(&#39;&#39;, &#39;_self&#39;); 
window.close() 
} else {} 
} 
</script> 
<input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" 
/>
Copy after login

4 , when the user clicks the "Close" button among the "Maximize", "Minimize", and "Close" buttons of the browser, a closing confirmation dialog box will also pop up.

The code is as follows:

<body οnbefοreunlοad="return &#39;真的要关闭此窗口吗?&#39;">
Copy after login

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!

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