473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Chrome / Safari not working...javascript problem?

57
Hi
I've checked out this page (and it works fine) in FF, IE, Opera, Chrome and Safari:

http://www.w3schools.com/dom/tryit.asp?filename=try_dom_list_loop

But when I try and tweak it for a site I'm working on, it doesn't work in Chrome and Safari.

I used their exact external javascript to load the xml file:

Expand|Select|Wrap|Line Numbers
  1. function loadXMLDoc(dname) 
  2. {
  3. var xmlDoc;
  4. if (window.XMLHttpRequest)
  5.   {
  6.   xmlDoc=new window.XMLHttpRequest();
  7.   xmlDoc.open("GET",dname,false);
  8.   xmlDoc.send("");
  9.   return xmlDoc.responseXML;
  10.   }
  11. // IE 5 and IE 6
  12. else if (ActiveXObject("Microsoft.XMLDOM"))
  13.   {
  14.   xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  15.   xmlDoc.async=false;
  16.   xmlDoc.load(dname);
  17.   return xmlDoc;
  18.   }
  19. alert("Error loading document");
  20. return null;
  21. }
And I use the same basic set up in javascript to display my results in the html page:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. xmlDoc=loadXMLDoc("xml/stations.xml");
  3.  
  4. x=xmlDoc.getElementsByTagName('city');
  5. for (i=0;i<x.length;i++)
  6. {
  7. document.write(x[i].childNodes[0].nodeValue);
  8. document.write("<br />");
  9. }
  10. </script>
Here's a shorter version of the xml file I'm using:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <stations>
  4.     <station>
  5.         <city>City 1</city>
  6.         <freq>105.7 FM</freq>
  7.     </station>
  8.     <station>
  9.         <city>City 2</city>
  10.         <freq>90.3 FM</freq>
  11.     </station>
  12. </stations>
So...it works in my 5 browsers when I use theirs on w3schools.com, but when I upload it all to our server, it won't work in Chrome and Safari.

I don't understand, any help would great. Thanks in advance!
Aug 4 '09 #1
1 7381
I think the problem is with the path you're requesting. Try to use path relative to the root (something like this '/mysite/otherdir/xml/stations.xml').

PS: Why don't you use the jQuery?
Aug 5 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: vendredi5h | last post by:
Hello, Yesterday I spent a lot of time to find why my javascript script was not working on Safari. I finaly found a solution but not the reason. And I'd like to know if someone could tell me if...
2
by: darren | last post by:
I have a small Javascript problem with that mutch love web browser safari, I tested the code on all other browsers PC (Win) and Linux and IE on the mac and it seams to work ok, but for some reason...
7
by: Tom | last post by:
I have an oo-type javascript program running perfectly on IE 6.0+, FF 1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X. 4. As usual, the Safari browser is not working correctly,...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
21
by: Stevo | last post by:
Look at the userAgent string: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13 It's based on a Safari so it'll suck. Time...
1
by: Guy Macon | last post by:
Serious Security Flaw in Google Chrome: http://www.readwriteweb.com/archives/security_flaw_in_google_chrome.php -- Guy Macon <http://www.GuyMacon.com/>
1
by: Gregor Kofler | last post by:
Setting the tabIndex property an element makes it focusable and attached key listeners respond. Or so it seems... This procedure works in - from what I've tested - IE6+, FF, Opera. However,...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
6
by: oneadvent | last post by:
This code works in Chrome and pulls a second drop down, but it will not work in IE6, (I dont have IE7/8 to check right now, but can later) and it works in FF, in IE it doesn't do anything at all. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.