Closing the Browser tab using js or jquery

白昼怎懂夜的黑 提交于 2020-01-14 12:47:32

问题


I want to close the current browser tab by clicking a button. window.close method does not work.


回答1:


You can't close the current browser tab with javascript. It would be annoying for the user if sites start to close themselves like this without the user intent so browsers simply do not allow this. Don't forget that the notion of a browser tab is not defined anywhere in the HTML nor the EcmaScript specifications, some browsers don't even have tabs.

You could of course write a plugin that you will install on your client's browser that will do the job.




回答2:


window.open('','_self');
window.close();


来源:https://stackoverflow.com/questions/8411978/closing-the-browser-tab-using-js-or-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!