2016-10-04 251 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); 

有趣的事情,它的工作的第一種方式在相當長的時間。不過,我不知道雷鳥有什麼變化。