]; 2. Close the current page, the code is [Close]."/> ]; 2. Close the current page, the code is [Close].">

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

How to turn off javascript web pages

coldplay.xixi
coldplay.xixiOriginal
2021-03-30 11:52:522693browse

Methods to close JavaScript web pages: 1. Close the window without any prompts, the code is [e90569361eb4f0b06f17f1f9dde68695]; 2. Close the current page, the code is [93fa92bce32e683c5c319f81ce1aa556Close5db79b134e9f6b82c0b36e0489ee08ed].

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>

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(&#39;&#39;, &#39;_self&#39;); 
window.close() 
} else {} 
} 
</script> 
<input id="btnClose" type="button" value="关闭本页" onClick="custom_close()" 
/>

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;">

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!

Statement:
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