gpt4 book ai didi

javascript - 在 firefox-extension 的新标签页中打开链接

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:37:50 26 4
gpt4 key购买 nike

我开发了一个 webapp,将其用作 Firefox 扩展。在 Firefox 中,我将它包含在这样的 iframe 中

<iframe src="http://mywebapp.com" flex="2" id="browserTable" name="table_frame"/>

现在我想在我的应用程序中添加一些传出链接。如果我只是使用像

这样的普通链接标记
<a href="http://mywebapp.com/contact">Contact</a>

链接在 iframe 中打开,由于它在侧边栏中,所以空间很小。有没有办法在主浏览器窗口的新选项卡中打开它?

最佳答案

target 属性允许您指定在哪个窗口中打开链接。您可以将这些特殊关键字放在属性中:

    _blank - new window
_self - same window (default)
_parent - the window which opened the current window, or the parent frame in a frameset
_top - overload the entire page, usually used in a frame context
"string" - in the window with an id of "string", or a new window if "string" is not the id of a current window

所以,这是您的 HTML:

<a href="http://mywebapp.com/contact" target="_blank">Contact</a>

编辑 在我们的评论讨论后做了一些研究,发现了这个片段:

var myUrl = "http://mesh.typepad.com";
var tBrowser = top.document.getElementById("content");
var tab = tBrowser.addTab(myUrl);
// use this line to focus the new tab, otherwise it will open in background
tBrowser.selectedTab = tab;

来源:http://mesh.typepad.com/blog/2004/11/creating_a_new_.html

让我知道这是否有效...我自己很好奇,但我目前的 FF 环境不是我可以轻松试验扩展开发的环境,我不想改变尝试。

关于javascript - 在 firefox-extension 的新标签页中打开链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5110129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com