Home  >  Article  >  Web Front-end  >  js implements the code to close the web page

js implements the code to close the web page

小云云
小云云Original
2018-03-02 11:35:213738browse

This article mainly shares with you the js code to close the web page, hoping to help everyone.

<button  onclick="window.opener=null;window.open(&#39;&#39;, &#39;_self&#39;);window.close()">关闭</button>

Very simple way to close this page, no other additional prompts:

window.opener=null; //返回对创建该窗口的 Window 对象的引用。window.open('', '_self'); //方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。window.close() //用于关闭浏览器窗口。

_self means opening a new page on this page, you can refer to the four attributes of target_ prarent,_blank,_selft,_top

<button  onclick="window.opener=null;window.open(&#39;&#39;, &#39;_self&#39;);window.close()">关闭</button>

A very simple way to close this page, no other additional prompts:

window.opener=null; //返回对创建该窗口的 Window 对象的引用。window.open('', '_self'); //方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。window.close() //用于关闭浏览器窗口。

_self means opening a new page on this page, you can refer to it Look at the four attributes of target _prarent, _blank, _selft, _top

Related recommendations:

HTML close web page pop-up window code_html/css_WEB-ITnose

The above is the detailed content of js implements the code to close the web page. 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