2011-02-24 123 views
3

我開發了一個web應用程序以將其用作Firefox擴展。在Firefox中,我把它包含在這樣一個iframe中在firefox-extension的新選項卡中打開鏈接

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

現在我想在我的應用程序中有一些傳出鏈接。如果我只是用正常的鏈路上的標記像

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

該鏈接在小空間中,因爲它是在側邊欄的iframe打開。有什麼方法可以在主瀏覽器窗口的新選項卡中打開它嗎?

回答

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 

所以,這裏是你的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環境不是一箇中,我可以很容易地擴展開發實驗,我不想改變要嘗試的事情。

+0

hm打開一個新的ff窗口,想要製表符,你認爲這是可能的嗎?也許與css3:D http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/會檢查出 – 2011-02-24 20:49:48

+0

一個新窗口??世界衛生大會?不應該是。這可能會受到Firefox中客戶端選項的影響,請檢查工具 - >選項,在「選項卡」選項卡上有一系列複選框。其中一個標題爲「在標籤中打開新窗口」。這是否被檢查?如果沒有,那就是爲什麼它打開一個新窗口。如果客戶端選項以這種方式配置,則無法「強制」用戶打開選項卡。否則,目標屬性應該打開一個新標籤。 – 2011-02-24 21:12:23

+0

這是檢查... – 2011-02-24 22:04:04

相關問題