我正在構建Firefox擴展,創建單個XMPP聊天連接,可以從所有選項卡和窗口訪問,所以我認爲,唯一的方法就是在JavaScript模塊中創建連接並將其包含在每個瀏覽器窗口中。糾正我,如果我錯了......mozilla擴展js模塊中的「文檔」?
編輯:我建立傳統的擴展使用XUL覆蓋,不使用SDK,並談論這些模塊:https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules
所以我複製到Strophe.js JS模塊。 Strophe.js使用這樣的代碼:
/*_Private_ function that creates a dummy XML DOM document to serve as
* an element and text node generator.
*/
[---]
if (document.implementation.createDocument === undefined) {
doc = this._getIEXmlDom();
doc.appendChild(doc.createElement('strophe'));
} else {
doc = document.implementation
.createDocument('jabber:client', 'strophe', null);
}
和以後使用doc.createElement()來創建XML節點(或HTML?)。
所有工作正常,但在模塊中我得到錯誤「錯誤:ReferenceError:文檔未定義」。 如何解決這個問題?
(一塊較大的確切代碼:http://pastebin.com/R64gYiKC)
我不usind SDK,而是讓傳統的擴展使用XUL覆蓋。 – wafflemoon