关闭当前选项卡 [英] Close Current Tab

查看:142
本文介绍了关闭当前选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网页上有一个关闭链接。我想它的功能,它关闭当前选项卡,当单击它。我写了

I have a close link on my web page. I would like to function it to close the current tab when click it. I have written

<a href="#" onclick = "javascript:self.close();">close</a>

上述代码似乎在Internet Explorer中运行良好。但它不工作在Mozilla Firefox和谷歌浏览器。请帮助我解决此问题。

The above code seems to be working well in Internet Explorer. But it is not working in Mozilla Firefox and Google Chrome. Please help me to resolve this.

推荐答案

您只能关闭自己创建的窗口/标签页。也就是说,您不能以编程方式关闭用户创建的窗口/标签。

You can only close windows/tabs that you create yourself. That is, you cannot programmatically close a window/tab that the user creates.

例如,如果您创建一个窗口 window.open ),您可以使用 window.close()关闭它。

For example, if you create a window with window.open() you can close it with window.close().

这篇关于关闭当前选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆