SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jun 18, 2007, 12:34 #1
- Join Date
- Feb 2003
- Location
- Knoxville, TN
- Posts
- 531
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
responseXML and getElementsByTagName in IE
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.
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 } } } }
-
Jun 20, 2007, 06:27 #2
- Join Date
- Feb 2003
- Location
- Knoxville, TN
- Posts
- 531
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
anyone know why IE isn't able to find the <script> tag within the responseXML?
-
Jun 26, 2007, 10:44 #3
- Join Date
- Feb 2003
- Location
- Knoxville, TN
- Posts
- 531
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Jun 28, 2007, 09:40 #4
- Join Date
- Apr 2007
- Location
- New London, CT
- Posts
- 172
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
try putting the script inside of the CDATA tag. I'm not too familiar with the XHR thing yet but i think that may be part of the problem
-
Jul 11, 2007, 13:02 #5
- Join Date
- Jul 2007
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I found your post while searching for a solution to the same problem. I just fixed it by changed the Content-Type in the header of the XML document I was working with from application/xhtml+xml to text/xml. I'm able to use getElementsByTagName on it now, so hopefully the same solution works for you without breaking something else you're doing.
Good luck,
Brian
Bookmarks