User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,929 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,254 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Javascript breaks IE - please help.

Join Date: Dec 2007
Posts: 75
Reputation: hielo is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
hielo hielo is offline Offline
Junior Poster in Training

Re: Javascript breaks IE - please help.

  #15  
Dec 13th, 2007
Wait a minute, I take that back. I left IE open long enough for the letter to reach the limit (3450), and then I got a pop-up error. The same with FF.

The reason for that is that when letter = 3449,
else if( letter < 3450 ){...}

is true and the content inside {...} is executed. That contents increments letter to 3450. So the next time that timeout calls alterText(), it attempts to execute this first:
underscore = document.getElementById("n" + letter).innerHTML;

since letter is now 3450 an such id does not exist, it throws a runtime error! You must check for the limit first.

Here's the revised code:
function alterText()
{
	if(letter < 3450)
	{
		underscore = document.getElementById("n" + letter).innerHTML;
      
		if(underscore == "_")
		{
			document.getElementById("n" + letter).innerHTML="&nbsp;";
		}
		else
		{
			document.getElementById("n" + letter).style.visibility="visible";
			document.getElementById("n" + letter++).style.color=genHex();
		}
	return true;
  	}
return false;
}
Reply With Quote  
All times are GMT -4. The time now is 5:52 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC