www.webdeveloper.com
Results 1 to 1 of 1

Thread: XML not loading in IE7 Object required?FF works...

  1. #1
    Join Date
    Sep 2008
    Posts
    17

    XML not loading in IE7 Object required?FF works...

    I'm sorry if this belongs in the Javascript forum btw I wasn't sure where to post it but I figured that if you know XML you must kinda know JS...
    I have to warn you it's gonna be a long post since I need to solve this (extreme curiosity) and I don't want to remake 63 pages in HTML haha...
    Anyway here's the problem...
    I have 4 pages...
    The first page is my HTML page (findarep.html)

    How I call my Javascript:
    Code:
    <div id="OH" onmouseover="this.style.fontWeight='bold';" onmouseout="this.style.fontWeight='normal';">
    <a href="javascript:newWindow('oh.html','','401','237','scrollbars=1,resizable=0,menubar=0,location=0,status=0,toolbar=0;')">
    <p>OH</p>
    </a></div>
    The second page is my Javascript page which is linked inside the HTML page (essential.js)
    Here's the XML parsing code:
    Code:
    function loadXMLDoc(dname)
    {
    var xmlDoc;
    if (window.XMLHttpRequest)
      {
      xmlDoc=new window.XMLHttpRequest();
      xmlDoc.open("GET",dname,false);
      xmlDoc.send("");
      return xmlDoc.responseXML;
      }
    // IE 5 and IE 6
    else if (ActiveXObject("Microsoft.XMLDOM"))
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.load(dname);
      return xmlDoc;
      }
    }
    And here's the newWindow function:
    Code:
    <script type="text/javascript" language="javascript">
    var win = null;
    function newWindow(mypage,myname,w,h,features) {
    	var winl = (screen.width-w)/2;
    	var wint = (screen.height-h)/2;
    	if (winl < 0) winl = 0;
    	if (wint < 0) wint = 0;
    	var settings = 'height=' + h + ',';
    	settings += 'width=' + w + ',';
    	settings += 'top=' + wint + ',';
    	settings += 'left=' + winl + ',';
    	settings += features;
    	win = window.open(mypage,myname,settings);
    	win.window.focus();
    }
    </script>
    The third is my popup window, it's basically an HTML file but contains my dynamically created Javascript.

    To be sure I added the XML parser JS again
    Code:
    <script type="text/javascript">
    function tableTrans() {
    	if (window.navigator.appName == "Netscape"||"Opera") {
    		document.getElementById('table1').style.opacity=0.8;
    		}
    	if (window.navigator.appName == "Microsoft Internet Explorer") {
    		document.getElementById('table1').filters.alpha.opacity=80;
    		}
    }
    function loadXMLDoc(dname)
    {
    var xmlDoc;
    if (window.XMLHttpRequest)
      {
      xmlDoc=new window.XMLHttpRequest();
      xmlDoc.open("GET",dname,false);
      xmlDoc.send("");
      return xmlDoc.responseXML;
      }
    // IE 5 and IE 6
    else if (ActiveXObject("Microsoft.XMLDOM"))
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.load(dname);
      return xmlDoc;
      }
    }
    </script>
    And here's the Script in my body:
    Code:
    <script language="javascript" type="text/javascript">
    xmlDoc=loadXMLDoc("sales.xml");
    
    // Table 1
    document.write('<table width="400" id="table1" border="0">');
    document.write('<tr>');
    document.write('<td>TERRITORY</td>');
    document.write('<td width="243">' + xmlDoc.getElementsByTagName('territory')[41].childNodes[0].nodeValue + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>REPRESENTATIVE</td>');
    document.write('<td><a href="' + xmlDoc.getElementsByTagName('url')[41].childNodes[0].nodeValue + '">' + xmlDoc.getElementsByTagName('representative')[41].childNodes[0].nodeValue + '<a/></td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>CONTACT</td>');
    document.write('<td>' + xmlDoc.getElementsByTagName('contact')[41].childNodes[0].nodeValue + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>EMAIL</td>');
    document.write('<td><a href="mailto:' + xmlDoc.getElementsByTagName('email')[41].childNodes[0].nodeValue + '">' + xmlDoc.getElementsByTagName('email')[41].childNodes[0].nodeValue + '<a/></td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>PHONE</td>');
    document.write('<td>' + xmlDoc.getElementsByTagName('phone')[41].childNodes[0].nodeValue + '</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>FAX</td>');
    document.write('<td>' + xmlDoc.getElementsByTagName('fax')[41].childNodes[0].nodeValue + '</td>');
    document.write('</tr>');
    document.write('</table>');
    // End of Table 1
    </script>
    And last but not least...The XML file which contains all the information that I need to create the dynamic content inside the HTML popup window... (sales.xml)

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <sales>
    	<item>
    		<country>Canada</country>
    		<state>AB</state>
    		<territory>Edmonton</territory>
    		<representative>Company Name</representative>
    		<phone>555.555.5555</phone>
    		<fax>555.555.5555</fax>
    		<contact>Johnny Laker</contact>
    		<email>johnny@company.com</email>
    		<url>http://www.thewebsiteofthecompany.com</url>
    	</item>
    </sales>
    Everything is working perfectly on Safari 3, Firefox 3.5.1 mac and 3.0.13 Windows, Google Chrome on Windows and Opera 9.64 mac
    If you need any more code just ask and you will receive...I just don't want to make this post WAY too long.

    Thank you so much,this community is awesome I,ve gotten a lot of help in my Javascript and now I'm hooked to Javascript haha!
    FREDZ.
    Last edited by SunnyHours; 08-06-2009 at 10:33 AM. Reason: div tag too long making it shorter for less scrolling...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles