I have written my first javascript block which functions correctly in IE, however nothing executes in FF or chrome. have I missed something. Also is there a way to stop IE from prompting to run it? TIA
Javascript
function getCondition()
{
if (window.XMLHttpRequest)
{// code for ie7+, firefox, chrome, opera, safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for ie6, ie5
xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","http://www.google.com/ig/api?weather=invercargill",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
i=0;
var x=xmlDoc.getElementsByTagName("current_conditions");
var c=(x[i].getElementsByTagName("condition")[0].getAttribute("data"));
var t=(x[i].getElementsByTagName("temp_c")[0].getAttribute("data"));
var img=(x[i].getElementsByTagName("icon")[0].getAttribute("data"));
document.getElementById("tempAPI").innerHTML="It's "+c+" and "+t+"°";
document.getElementById("tempIMG").innerHTML="<img src='http://www.google.com"+img+"' alt='weather image' />";
}
HTML
<body class="t" onload="getCondition()">