2016-10-04 3 views
0

Thunderbird Addon에서 PasteHyperlink이라고 불리는 메시지 작성 창에 html 요소를 삽입하는 루틴이 있습니다. 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,하지만 난이에 후드 변경 어떤 고장 또는 이유에 대해 이야기 그 어느 곳 아무것도 찾을 수 없습니다 Thunderbird 45.

왜이 기능이 작동하지 않고 대신 무엇을해야합니까?

답변

0

음, 생각났습니다.

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

재미있는 것은, 그것은 꽤 오랜 시간 동안 첫 번째 방법을 일이에

var thiseditor = gMsgCompose.editor; 

:이 변경되었습니다. 하지만 썬더 버드에서 어떤 변화가 있었는지는 알 수 없습니다.