ok - basically i'm pulling HTML into a page via AJAX. in these HTML pages there could be some javascript and if there is javascript i want to execute the script.
the following works perfect in firefox. in IE the page will be created perfectly, but it's not finding any <script> tags.
pagereq.responseXML.getElementsByTagName("script").length returns 1 for firefox and 0 for IE in an HTML document containing <script>.Code:// these are parts pulled out of the overall script if (pagereq) { pagereq.onreadystatechange = loadpage; pagereq.open("GET", url, false); if (msie < 0) { pagereq.overrideMimeType("text/xml"); } // override the mime type so we can find any <script> tags - only firefox needs this pagereq.send(""); } function loadpage() { if (pagereq.readyState == 1) { //loading /* start any loading actions */ } else if (pagereq.readyState == 4) { if (pagereq.status == 200) { document.getElementById(content).innerHTML = pagereq.responseText; if (pagereq.responseXML.getElementsByTagName("script").length) { // see if the page has any javascript eval(pagereq.responseXML.getElementsByTagName("script")[0].innerHTML); // execute the javascript } } } }




Bookmarks