Firefox附加组件href无法正常工作

时间:2013-05-09 08:13:30

标签: firefox firefox-addon href add-on

firefox附加组件无法正常工作的

href

我创建了一个firefox附加组件,它将一个按钮插入到页面中,并带有href属性。有人可以告诉我为什么链接不起作用。我使用chrome扩展程序做了同样的事情,一切都按照我在chrome上的预期工作。页面上插入的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>

2 个答案:

答案 0 :(得分:0)

我在firefox和chrome中测试了你的代码,一切都很好。粘贴整个代码或提供我们可以看到问题的链接,因为问题不在上面的代码中。

答案 1 :(得分:0)

我知道它有点晚了,但是这里是如何从插件添加页面链接:

element是您要添加链接的元素(此案例位于Google首页

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上尝试了它,它添加了一个很好的链接到CélineDion的歌曲:D。

相关问题