SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up 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<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 ..

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Location
    Maidenhead, UK
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This might not be your problem, but always use the 'var' statement to declare variables:

    i.e. in your code:

    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?
    -------------------------------------------------------
    UK postcode->address lookup : www.CraftyClicks.co.uk
    a piece of my brain : adam.stylo.name (at your own risk)
    -------------------------------------------------------

  3. #3
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Error 404: Life not found silver trophybronze trophy
    Join Date
    Dec 2007
    Location
    UK Nr Manchester
    Posts
    3,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    It's 530 people, but do you really get it?
    ImgWebDesign - Web design in Buxton, High Peak, Derbyshire UK.

  5. #5
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,269
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    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.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •