在名为PasteHyperlink的Thunderbird Addon中,我有一个例程,它将一个html元素插入到Message Compose窗口中。
这曾经在Thunderbird中工作,但现在我得到了这个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,但我无法找到任何可以解释为什么会在Thunderbird 45中被破坏或发生变化的地方。
为什么这样做不起作用,我应该怎么做呢?
答案 0 :(得分:0)
好吧,我想我弄明白了。我改变了这个:
var thiseditor = gMsgCompose.editor;
到此:
var thiseditor = gMsgCompose.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
有趣的是,它在很长一段时间内都是第一种方式。但我不知道Thunderbird发生了什么变化。