georgedw Posted January 29, 2009 Share Posted January 29, 2009 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title></title><script type="text/javascript" language="javascript"><!--var myText = "Hello, World";var tempText ="";var i = 0;function scrollText() { if (i < myText.length) { tempText = tempText + myText; document.getElementById('p1').innerHTML = tempText; i++; var t1= setTimeout("scrollText()",300); } } onload=scrollText;//--></script></head><body><p id="p1"></p></body></html>This code works fine in Safari and Opera, but when run in IE7 it types undefined for each character (12 times) with the proper >3 second delay.Help greatly appreciated. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 30, 2009 Share Posted January 30, 2009 IE doesn't treat strings as arrays, you'll need to use another way to get each character. Link to comment Share on other sites More sharing options...
alexnofue Posted January 30, 2009 Share Posted January 30, 2009 Hi, JSG is right but you can split the string to get ti to work:function scrollText(){var arrText = myText.split("");if (i < arrText.length){tempText = tempText + arrText;document.getElementById('p1').innerHTML = tempText;i++;var t1= setTimeout("scrollText()",300);}}that way you are using an array instead of a string.hope this helps. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.