1
我想要做的是在我的Firefox插件中包含Google翻譯API。 我正在用插件生成器編寫它。 我已經嘗試在文檔的頭部分動態加載腳本,但它不起作用,我沒有任何錯誤,什麼也沒有。 下面的代碼:在Firefox中使用外部JavaScript文件
var fileref = doc.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", "https://apis.google.com/js/client.js?onload=st.gApiInit");
if (typeof fileref != "undefined") {
object=doc.getElementsByTagName("head")[0];
object.appendChild(fileref);
}
如果我看一個網頁的源代碼,我找不到添加的元素
什麼是「對象」?那應該是'窗戶'嗎?什麼是'doc'? (我從來沒有開發FF附加組件) – Ian 2013-04-11 22:01:26