如何使用javascript关闭当前选项卡? [英] How to close current tab using javascript?
本文介绍了如何使用javascript关闭当前选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用javascript / Jquery关闭当前标签。但我没有找到任何解决方案。我读到window.close()仅适用于使用 window.open()
方法打开的窗口。那么有没有办法向系统发送命令,用户按ctrl + w也关闭此窗口。 小提琴
I want to close current tab using javascript/Jquery. But I did not find any solution. I read that the window.close() only works with window which is open with window.open()
method. So is there any way to send command to system that user press ctrl+w which is also close this window. fiddle
function down(){
window.close()
}
推荐答案
有可能。我在整个互联网上搜索了这个,但是当我接受微软的一项调查时,我终于得到了答案。
It is possible. I searched the whole internet for this, but once when i took one of Microsoft's survey, I finally got the answer.
试试这个:
window.top.close();
这将为您关闭当前标签。
this will close the current tab for you.
这篇关于如何使用javascript关闭当前选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文