2013-05-09 45 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