"for loop" works in FF but not in IE

  • Thread starter Patrick Sullivan
  • Start date
P

Patrick Sullivan

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>
 
R

Randy Webb

Patrick Sullivan said the following on 6/9/2006 8:55 AM:
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];

Firefox executes that statement without a syntax error? I ask because FF
doesn't support innerText in any form unless you create it yourself.
 
P

Patrick Sullivan

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

Randy Webb said:
Patrick Sullivan said the following on 6/9/2006 8:55 AM:
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];

Firefox executes that statement without a syntax error? I ask because FF
doesn't support innerText in any form unless you create it yourself.
http://www.JavascriptToolbox.com/bestpractices/
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top