Open link in new tab in firefox-extension

I developed webapp to use it as a Firefox extension. In Firefox, I enable it with an iframe, like this

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

Now I want to have some outbound links in my application. If I just use a regular link, for example

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

the link opens in an iframe, which is small in space, as it is in the sidebar. Is there a way to open it in a new tab in the main browser window?

+3
source share
1 answer

The attribute targetallows you to specify in which window to open the link. You have these special keywords that you can put in an 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>

:

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 , dev, , .

+7

Source: https://habr.com/ru/post/1794547/


All Articles