I am having an issue with the following Javascript in Internet Explorer 6.
it displays an error in the IE6 toolbar, saying invalid.
it works fine in IE7,8 and Firefox. I NEED it to work in IE6, it's a requirement.
I didn't realize it didnt work until someone called me.. oops!
The script create an onload function and then attempts to retrive data from the primary source and if it fails it goes to a secondary. I can't use a Body onLoad as it's already locked into a temple. Thsi code orks flawlessly on other versions of IE.
Can someone take a look and see if there is something I can do to this script to make it play nice with IE6?
Code:
<script type="text/javascript">
window.onload = function()
{
LoadPrimaryDataSourceURL("
primary_re
sultsnew.a
sp"),init(
);
};
function LoadPrimaryDataSourceURL(d
est) {
try {
var xreq = XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.X
MLHTTP");
}
catch (e) {}
xreq.onreadystatechange = function() {
if (xreq.readyState == 4) {
if (xreq.status == 200) {
document.getElementById("o
utput").in
nerHTML = xreq.responseText;
}
else {
LoadBackupDataSourceURL("s
econdary_r
esultsnew.
asp"); // Try this if we did not succeed...
}
}
}
xreq.open("GET", dest, true);
xreq.send(null);
}
function LoadBackupDataSourceURL(de
st) {
try {
var xreq = XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.X
MLHTTP");
}
catch (e) {}
xreq.onreadystatechange = function() {
if ((xreq.readyState == 4) && (xreq.status == 200)) {
document.getElementById("o
utput").in
nerHTML = xreq.responseText;
}
}
xreq.open("GET", dest, true);
xreq.send(null);
}
</script>
<div id="loading" style="position:top; width:100%; text-align:center; color : 666699; font-size:14px; font-family : Verdana, Arial, Helvetica, sans-serif; top:300px;";>
<br>Please wait while your request is being processed.<br><br>
<img src="loadingajax.gif" border=0></div>
<script>
var ld=(document.all);
var ns4=document.layers;
var ns6=document.getElementByI
d&&!docume
nt.all;
var ie4=document.all;
if (ns4)
ld=document.loading;
else if (ns6)
ld=document.getElementById
("loading"
).style;
else if (ie4)
ld=document.all.loading.st
yle;
function init()
{
if(ns4){ld.visibility="hid
den";}
else if (ns6||ie4) ld.display="none";
}
</script>
<div id="output"></div>