Link to home
Start Free TrialLog in
Avatar of joco22
joco22

asked on

"Object Error" in Internet Explorer 7

This code runs in my FrontPage development environment, but when I upload it to my Web site I always get the error message "object Error". I click "OK", the error popup box disappears and the code only completes the first step, getting the weather station name. The data from that weather station (namely, temperature and relative humidity), are not retrieved. When I run this page in Firefox, I get a more elaborate error message that points to a problem in Line 27, which is the line
xmlDoc.load(url);
I suspect that neither browser likes this line at all, but I am puzzled that it runs fine in FrontPage. You should know that the source XML document, ZIP_Codes_and_XML_Stations_3.xml, is massive, about 43,000 lines.
Advice would be greatly appreciated.
<html>
<head>
<script type="text/javascript">
function parseXML(){
    if(window.ActiveXObject){
        try{ //Internet Explorer
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        }
        catch(e){
        alert(e.message);
        return;
        }
    }else{
        try{ //Firefox, Mozilla, Opera, etc.
            xmlDoc=document.implementation.createDocument("","",null);
        }
        catch(e){
            alert(e.message);
            return;
        }
    }
    xmlDoc.async=false;
    try{
        xmlDoc.load("http://www.Zunis.org/P180/ZIP_Codes_and_XML_Stations_3.xml");
        var url = parent.xmlDoc.getElementsByTagName("a90210")[0].childNodes[0].nodeValue;
        document.getElementById("a90210").innerHTML = url;
        xmlDoc.load(url);
        parent.document.getElementById("temp_f").innerHTML=xmlDoc.getElementsByTagName("temp_f")[0].childNodes[0].nodeValue;
        parent.document.getElementById("relative_humidity").innerHTML=xmlDoc.getElementsByTagName("relative_humidity")[0].childNodes[0].nodeValue;
    }
    catch(e){
        alert(e);
    }
}
</script>
</head>
<body onload="parseXML()">
<h1>Heat Stress Adviser</h1>
<b>Weather Station:</b> <span id="a90210"></span><br/>
<b>Temperature:</b> <span id="temp_f"></span><br/>
<b>Relative Humidity:</b> <span id="relative_humidity"></span>
</p>
</body>
</html>

Open in new window

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

You will not be able to run this in FF due to security reasons. So the two errors are not related
You need to alert(e.message) and you will see you get "Access Denied"
Avatar of joco22
joco22

ASKER

Thanks, mplungjan.
Since this approach seems doomed to failure, could you please recommend an approach that would work? What I want to do is pretty straightforward:
1. The user enters a ZIP code into an input box.
2. The program looks up the US government weather station that is closest to the ZIP code. I already have this information for each of the 43,000 ZIP code, in an XML file.
3. The program retrieves the current temperature and relative humidity from the weather station selected in Step 2.
4. The information from step 3 is used, together with cloud density and time information to calculate a measure of heat stress, the Wet Bulb Globe Temperature.
5. The user chooses a sport, and recommendations are given re:physiologic stress for that sport in those conditions.
6. For an example, see http://www.zunis.org/P180/Airport_RH_to_WBGT.htm
7. I am just trying to automate the process, to make getting this information easier for the user.
Thanks very much for your help.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial