Jump to content

Text Scrolling Won't Work In Ie 7


georgedw

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...