I have developed a webapp to use it as Firefox extension. In Firefox I include it with an iframe like this
<iframe src="http://mywebapp.com" 开发者_Python百科flex="2" id="browserTable" name="table_frame"/>
Now I want to have some outgoing links in my app. If I just use normal link markup like
<a href="http://mywebapp.com/contact">Contact</a>
the link is opened in the iframe that is small in space since it is in the sidebar. Is there any way to open it in a new tab in the main browser window?
The target
attribute allows you to specify which window to open a link in. You have these special keywords you can place in the attribute:
_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
So, here is your HTML:
<a href="http://mywebapp.com/contact" target="_blank">Contact</a>
EDIT Did some research after our discussion in comments, and found this snippet:
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;
Source: http://mesh.typepad.com/blog/2004/11/creating_a_new_.html
Let me know if that works out... curious myself, but my current FF environment is not one in which I can easily experiment with extension dev, and I don't want to change things to try.
精彩评论