Firefox 侧边栏扩展链接已加载到新的浏览器选项卡中。 如何?
我有一个 friefox 侧边栏扩展。 如果通过单击工具栏图标打开它,我会加载一个网页(我编写的)。 现在,如果用户单击网页上的链接(已加载到侧边栏中),我希望链接的网页在主窗口的新选项卡中打开。 我在网页标记中尝试使用此方法:
<a target="_content" href="http://www.google.com">Google</a>
但是链接在具有焦点的选项卡中打开,而不是在新选项卡中打开。
请帮忙。
谢谢。
I have a friefox sidebar extension. If its opened by clicking on the toolbar icon I load it with a webpage ( that I have authored ). Now, if the user clicks on the link on the webpage ( thats loaded into the sidebar ) I want the linked webpage to open up in a new tab of the main window. I tried with this in my webpage markup:
<a target="_content" href="http://www.google.com">Google</a>
But the link opens up in the tab that has focus and not in a new tab.
Please help.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您改用 target="_blank",FF(版本 3)应该为其打开一个新选项卡。 还没有从侧边栏尝试过,但值得一试。
If you use target="_blank" instead, FF (version 3) should open a new tab for it. Haven't tried it from a sidebar, but it's worth giving a shot.
实际上,无法将网页(其链接位于加载到侧边栏扩展中的另一个网页中)加载到浏览器中的新选项卡上。 唯一的方法是使用 javascript。 这必须在特权条件下执行(意味着作为扩展的一部分),如下所示:
编辑:
上述添加浏览器选项卡的技术在这种情况下不起作用。 根据这篇文章,在侧边栏中运行的代码无法访问主窗口。 因此,在使用 gBrowser 之前,我首先访问了浏览器窗口。 以下是从我使用的网站上获取的代码,并且工作正常:
在访问浏览器窗口后,我通过 getBrowser 函数访问 gBrowser,如下所示:
在主窗口浏览器中打开一个新选项卡。
Actually, there is no way to load a webpage ( whose link was in another webpage loaded into the sidebar extension ) onto a new tab in the browser. The only way is to use javascript. That has to execute under privileged conditions ( meaning as part of an extension ) like below:
EDIT:
The above technique of adding a browser tab did not work in this case. According to this article code running in the sidebar does not have access to the main window. So first up I got access to the browser window before using gBrowser. Here is the code taken from the website that I used and works properly:
After I got access to the browser window I accessed gBrowser through the getBrowser function like below:
The opens up a new tab in the main window browser.
这更取决于所使用的浏览器。 Firefox 和 Opera,以及我确信最新的 IE,都会将“新窗口”显示为新选项卡,除非用户首选项另有指定。
This is more dependent on the browser that is being used. Firefox and Opera, and I'm sure the newest IE, display "new windows" as a new tab unless otherwise specified by user preference.