关闭当前选项卡

编程入门 行业动态 更新时间:2024-10-27 18:33:50
本文介绍了关闭当前选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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().

更多推荐

关闭当前选项卡

本文发布于:2023-11-06 21:59:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564785.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!