"for loop" works in FF but not in IE

Discussion in 'Javascript' started by Patrick Sullivan, Jun 9, 2006.

  1. In this for loop, IE skips over the animation function until the end of the
    loop and only aninmates the last phrase. Firefox does it right. Loop is
    right below, entire script is below that. This script uses the Yahoo GUI
    library (beta) for animation.

    for (var c=0; c < index; c++) {
    document.getElementById("sample").innerText = myArray[c];
    var myanim = new YAHOO.util.Anim('sample', {
    fontSize: {from: 0, to: 50},
    opacity: {from: 0.5, to: 1}
    }, 2);
    myanim.animate();

    if (c >= myArray.length)
    c=0;
    };
    };


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>test10</title>
    <script language="JavaScript" type="text/javascript"
    src="yui/build/yahoo/yahoo.js"></script>
    <script language="JavaScript" type="text/javascript"
    src="yui/build/dom/dom.js"></script>
    <script language="JavaScript" type="text/javascript"
    src="yui/build/animation/animation.js"></script>
    <script language="JavaScript" type="text/javascript"
    src="yui/build/event/event.js"></script>

    <script type="text/javascript">
    var myArray = new Array("note 1","note 2","note 3","note 4","note 5");

    var index = myArray.length;
    var animtest = {};
    animtest.init = function() {
    for (var c=0; c < index; c++) {
    document.getElementById("sample").innerText = myArray[c];
    var myanim = new YAHOO.util.Anim('sample', {
    fontSize: {from: 0, to: 50},
    opacity: {from: 0.5, to: 1}
    }, 2);
    myanim.animate();

    if (c >= myArray.length)
    c=0;
    };
    };

    YAHOO.util.Event.addListener(window, 'load', animtest.init);
    </script>
    </head>
    <body>
    <div id="sample"><span id="sampletext" style="font-family:Arial, Helvetica,
    sans-serif">SOMETEXT</span></div>
    </body>
    </html>
     
    Patrick Sullivan, Jun 9, 2006
    #1
    1. Advertisements

  2. Patrick Sullivan

    Randy Webb Guest

    Patrick Sullivan said the following on 6/9/2006 8:55 AM:
    Firefox executes that statement without a syntax error? I ask because FF
    doesn't support innerText in any form unless you create it yourself.
     
    Randy Webb, Jun 9, 2006
    #2
    1. Advertisements

  3. heheh, firefox did much better than IE. innerText has been incorporated into
    several browsers besides IE. I know it's not standards compliant. I am doing
    it entirely different now, using innerhtml. Also not standards compliant.
    thanks guys.

    --

    Patrick Sullivan, AA-BA, BA-IT

    http://www.JavascriptToolbox.com/bestpractices/
     
    Patrick Sullivan, Jun 9, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.