Jump to content

Text Scrolling Won't Work In Ie 7


georgedw
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...