我的XUL應用程序需要動態地加載腳本,爲了這個,我得到的是,在常規的HTML/JS應用工作的功能:
function loadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
的東西,應該在XUL工作:
function loadScript(url)
{
var e = document.createElement("script");
//I can tell from statically loaded scripts that these 2 are set thru attributes
e.setAttribute('type' , "application/javascript"); //type is as per MDC docs
e.setAttribute('src' , url);
//XUL apps attach scripts to the window I can tell from firebug, there is no head
document.getElementsByTagName("window")[0].appendChild(e);
}
標籤得到正確添加的腳本,屬性看起來不錯,但它並沒有在所有的工作,執行這些加載的腳本里面沒有代碼甚至解析。
任何人都可以暗示可能會發生什麼?
T.
挑戰在哪裏? ;) – lucideer 2010-07-16 14:14:56