2013-05-09 48 views
1

HREF附加不工作Firefox插件HREF不能在Firefox的環境中工作

我做了一個Firefox的插件,插入按鈕插入到頁面中,與A HREF attribute.Could誰能告訴我爲什麼鏈接不working.I取得了Chrome擴展一樣,一切都會按我預期chrome.The插入HTML頁面上看起來是這樣的:

<a class="yt-uix-button yt-uix-button-primary" 
    style="color: white; float: right;" 
    href="http://www.youtube.com/watch?v=Y8HOfcYWZoo">Download MP3</a> 

回答

0

我在Firefox和Chrome測試你的代碼,一切都很好。粘貼整個代碼或給出一個鏈接,我們可以看到問題,因爲問題不在你的上面的代碼。

+0

的HTML代碼工作正常,問題是,當我嘗試使用它注入到當前選項卡。我的Firefox插件 – 2013-05-09 08:39:20

+0

@ user1531371你是怎麼注入它的,exa ctly? – 2013-05-09 15:01:41

0

我知道這是有點晚了,但這裏是如何的鏈接從一個插件添加到頁面:

element是您要的鏈接添加到元素(這裏指的是對谷歌的主頁

var element = window.content.document.getElementById("gbqfw"); 
var htmlns = "http://www.w3.org/1999/xhtml"; 
var ins = document.createElementNS(htmlns, "a"); 

ins.className = "yt-uix-button yt-uix-button-primary"; 

// changed color to green to be visible on google homepage 
// since i don't have your css classes 

ins.style="color: green; float: right;"; 
ins.href="http://www.youtube.com/watch?v=Y8HOfcYWZoo"; 
ins.innerHTML = "Download MP3" 

element.appendChild(ins); 

剛在google.com,它增加了一個不錯的鏈接到席琳·迪翁的歌:d