W
warteschlange
i want to postload javscript from another javascript.
This works fine in
firefox and IE6
for macIE i can use an Iframe to load the code and inject it with
insertAdjacentHTML
The problems arise with safari and opera.
both load the new code with XMLHttpRequest, but the code is no
'executable'
To make this possible on IE i had to use the magic 'DEFER' attribute.
(Sync or Async ist not the issue)
This is a extract of the working code:
for testing try to insert "var str = 'function a(){alert(1)}'; with
insertAdjacent or another way
and call the function afterwards.
i'm stuck now.
opera and safari experts needed...
Andres
This works fine in
firefox and IE6
for macIE i can use an Iframe to load the code and inject it with
insertAdjacentHTML
The problems arise with safari and opera.
both load the new code with XMLHttpRequest, but the code is no
'executable'
To make this possible on IE i had to use the magic 'DEFER' attribute.
(Sync or Async ist not the issue)
This is a extract of the working code:
Code:
//----------------
function importJS(url){
var script = syncGetFile(url);
document.body.insertAdjacentHTML("beforeEnd",
"<span> </span><SCRIPT DEFER>" + script + "</SCRIPT>");
}
//----------------
function syncGetFile(url){
var xmlhttp = _XMLHttpRequest_init();
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
return xmlhttp.responseText;
}
function _XMLHttpRequest_init() {
.....
}
if(typeof HTMLElement!="undefined" && !
HTMLElement.prototype.insertAdjacentElement){
HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sHTML) {
}
}
insertAdjacent or another way
and call the function afterwards.
i'm stuck now.
opera and safari experts needed...
Andres