Code works in FF but not in IE

Hi All,

I am trying to create a client-side script, which will import URLs from an XML file and show fade-in fade-out effect.

<html>
<body>

<div align=‘right’>

<script type=“text/javascript” src=“http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script>
<script type=“text/javascript” src=“js/fadeslideshow.js”></script>
<script type=“text/javascript”>

var myCars=new Array(); // regular array (add an optional integer
var imageobj=new Image();
var xmlDoc;
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else // Internet Explorer 5/6
{
xhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}

xhttp.open(“GET”,“xml/textcontent1.xml”,false);
xhttp.send(“”);

xmlDoc=xhttp.responseXML;

x=xmlDoc.getElementsByTagName(“PAGEID”);

    for (i=0;i&lt;x.length;i++)
    {
        txt=x[i].firstChild.nodeValue;
        myCars[i]= new Array();
        myCars[i][0]=txt;
        myCars[i][1]="";
        myCars[i][2]="";
    }
var mygallery2=new fadeSlideShow({
wrapperid: "fadeshow2", //ID of blank DIV on page to house Slideshow
dimensions: [666, 467],
imagearray: myCars,
displaymode: {type:'auto', pause:5000, cycles:0, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 2000, //transition duration (milliseconds)
descreveal: "always",
togglerid: "fadeshow2toggler"

})
</script>
<div id=“fadeshow2”></div>
<div id=“fadeshow2toggler” style=“width:666px; text-align:center; margin-top:0px”></div>
</div>
</body>
</html>

This code works in FF and not in IE. Can anyone please help …

This might not be your problem, but always use the ‘var’ statement to declare variables:

i.e. in your code:


var x=xmlDoc.getElementsByTagName("PAGEID");

for (var i=0; i<x.length; i++)


I had a strange problem in IE a few days ago - if you leave out ‘var’ you get some very criptic errors from IE if your html has any element ids the same as those JS vars. Worth checking quickly if this is the case here.

By the way - what errors do you get in IE? Did you check with FF Error Console that there are no warnings/errors?

Follow this:

IE->Tools->internetOptions->Security->CustomLevel-> and check the ActiveX object and Plugins , enable them.

Shot in the dark, but ActiveX might be disabled.

Can’t help you with your specific problem but I can say that when you have this situation it’s your code that’s right usually. When it works in IE but not FF, your code is wrong. It’s about the only use IE has.

Still, agreed with styloa, “var” should be used to declare all variables all the time.

While unless in a function it’ll have global scope, vars without “var” are global in every case, which is not what you want, and I can imagine IE having trouble with that. Also, the new “strict” JS version thingie FF has should also flag that, as would JSLint.