在firefox-extension的新标签中打开链接 [英] Open link in new tab in firefox-extension

查看:105
本文介绍了在firefox-extension的新标签中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个web应用程序来使用它作为Firefox的扩展。在Firefox中,我将它包含在这样的iframe中:

$ p $ lt; code>< iframe src =http://mywebapp.comflex = 2id =browserTablename =table_frame/>

现在我想在我的应用程序中有一些传出链接。如果我只是使用正常的链接标记,如

 < a href =http://mywebapp.com/contact>联系与LT; / A> 

这个链接在iframe中打开。有什么办法可以在主浏览器窗口的新选项卡中打开它?

解决方案

属性允许您指定打开链接的窗口。您可以在属性中添加以下特殊关键字:

  _blank  - 新窗口
_self - 同一窗口(默认)
_parent - 打开当前窗口的窗口或框架集中的父框架
_top - 整个页面,通常用在框架上下文
string - 窗口中的id为string,或者如果string不是当前窗口的id,则为新窗口
< code


$ b $ p


code>< a href =http://mywebapp.com/contacttarget =_ blank>联系人< / a>

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

  var myUrl =http://mesh.typepad.com; 
var tBrowser = top.document.getElementById(content);
var tab = tBrowser.addTab(myUrl);
//使用这一行来关注新标签,否则会在后台打开
tBrowser.selectedTab = tab;

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



让我知道如果... ...好奇自己,但我目前的FF环境是不是我可以轻松地尝试扩展开发,我不想改变的事情尝试。

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" 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.

这篇关于在firefox-extension的新标签中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆