在firefox-extension的新选项卡中打开链接

Upv*_*ote 3 javascript firefox-addon

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

<iframe src="http://mywebapp.com" flex="2" id="browserTable" name="table_frame"/>
Run Code Online (Sandbox Code Playgroud)

现在我想在我的应用程序中有一些外向链接.如果我只是使用正常的链接标记

<a href="http://mywebapp.com/contact">Contact</a>
Run Code Online (Sandbox Code Playgroud)

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

Chr*_*ker 7

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
Run Code Online (Sandbox Code Playgroud)

那么,这是你的HTML:

<a href="http://mywebapp.com/contact" target="_blank">Contact</a>
Run Code Online (Sandbox Code Playgroud)

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

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;
Run Code Online (Sandbox Code Playgroud)

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

让我知道,如果这样做...好奇我自己,但我目前的FF环境不是我可以轻松尝试扩展开发的环境,我不想改变尝试的东西.