2016-10-04 160 views
0

在我的Thunderbird插件PasteHyperlink中,我有一个插入HTML元素到Message Compose窗口的例程。insertElementAtSelection停止工作

这用在雷鸟的工作,但现在我得到这个js错误:

Error: TypeError: thiseditor.insertElementAtSelection is not a function 

然而,似乎thiseditor被定义的,因为它不启动警报。

下面是函数的代码,我已经减少到基本功能:

var thiseditor = gMsgCompose.editor; 
if (!thiseditor){ alert("Dude, the gMsgCompose.editor is broken") };  
let link = thiseditor.document.createElement("a"); 
link.setAttribute("href", "http://stackoverflow.com"); 

link.textContent = "Display Text"; 
thiseditor.insertElementAtSelection(link, false); 

MDN has this documentation,但我不能在任何地方找到任何关于为什么这是损坏或发动机罩下的是什么改变了会谈雷鸟45.

为什么这退出工作,我应该怎么做呢?

回答

0

嗯,我想我想通了。我改变了这一点:

var thiseditor = gMsgCompose.editor; 

这样:

var thiseditor = gMsgCompose.editor.QueryInterface(Components.interfaces.nsIHTMLEditor); 

有趣的事情,它的工作的第一种方式在相当长的时间。不过,我不知道雷鸟有什么变化。