I'm using XmlHttpRequest to get the content of the file and display it. I have a little bit of javascript on the page being retrieved, but that javascript isn't work. Is there a way to get it read the javascript properly?
You can do it like this.
[tt]
//add some non-empty filler ahead of it (somehow arbitrary)
var s="<span style='display:hidden;'> <\/span>";
s+=http_request.responseText;
var oelem=document.getElementById("changerDiv");
oelem.innerHTML="";
if (!!window.ActiveXObject) {
oelem.insertAdjacentHTML("beforeEnd",s);
} else if (!!window.netscape) {
var r=document.createRange();
r.setStartBefore(oelem);
var ohtmlfrag=r.createContextualFragment(s);
oelem.appendChild(ohtmlfrag);
}
[/tt]
You should be done. Note also that for ie, defer attribute is needed for the script component. That you've to do the design proper at server-side.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.