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('', '_self');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('', '_self');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!