我在我的网页上有一个关闭链接。我想它的功能,它关闭当前选项卡,当单击它。我写了
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().
更多推荐
关闭当前选项卡
发布评论