爱玩科技网
您的当前位置:首页js实现关闭网页的代码

js实现关闭网页的代码

来源:爱玩科技网


本文主要和大家分享js实现关闭网页的代码,希望能帮助到大家。

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

很简单的关闭本页面的方法,没有其他额外的提示:

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

_self是在本页面打开一个新页面的意思,可以参考看target的四种属性_prarent,_blank,_selft,_top

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

很简单的关闭本页面的方法,没有其他额外的提示:

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

_self是在本页面打开一个新页面的意思,可以参考看target的四种属性_prarent,_blank,_selft,_top

显示全文