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 361,925 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 2,670 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.

  #18  
Dec 13th, 2007
Originally Posted by tefflox View Post
Thanks, Hielo.. I did tinker with firebug last night, after fixing a few things, but could not find where the errors would be displayed.
Once firebug is installed, you will see a little icon on the lower right-hand side of your browser. The icon will be a small check mark on a green background if there are no reported errors on the page, or an x on a red background if errors exist. However, you still need to configure it for it to show the "x" icon upon javascript errors. To do so, click on the icon > options > Show Javascript Errors


I'm kind of in the dark as to the cover (URI) page, tho I suspect it may be something to do with running these functions concurrently:

    setInterval("alterText();", 110);
    setInterval("alter();", 100);
    setInterval("alter();", 100);   
When I looked at this page, nothing had changed. You were not checking for the limit (23).

Actually, I counted 24 letters in liste v nligh v tpoet v ryjou v rnal iv
Yes, this is correct. But you began numbering the letters at 0. So, the 24th letter will have id "n23". So, when you add a limit check to it, you cannot exceed 23. Refer to my previous post to see how I addressed this issue on the other page.


-- & since, to my knowledge, employing Math.floor() requires it, I changed the delimiting constant herewith from 24 to 25:
Math.random() by itself will give you a floating number that will be at least 0 and a number that is "almost 1". When you multiply that number by 24, you end up with a number that is at least 0 and "almost 24" (perhaps 23.99999999999999999999999999999999). Then Math.floor() basically just keeps the integer part, and hence, your number range will be [0, 23]. That's why alter will never trigger any errors on that page, since your letters are labeled from id="n0" ... id="n23".


  function alter() {  
   	i = "n" + Math.floor(Math.random() * 25);
  	document.getElementById(i).style.color=genHex();	
   }
Again, that 25 should be changed back to 24. Otherwise you will start getting errors triggered by alter() as well, since 25 changes the possible ids to [0,24], but there is no id="n24".

These changes are live: http://listenlight.net. I am marking the problem solved. If you will, please confirm that it functions in IE without errors.

The errors are still there. Your functions should be changed to:
function alter() {  
   	i = "n" + Math.floor(Math.random() * 24);
  	document.getElementById(i).style.color=genHex();	
   }
  
  var letter = 0;
  
function alterText()
{
	if(letter < 24)
	{
		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;
}
Last edited by hielo : Dec 13th, 2007 at 2:03 pm. Reason: Incompleteness
Reply With Quote  
All times are GMT -4. The time now is 10:38 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC