Jump to content

CalBear

Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

1 Neutral

About CalBear

  • Rank
    Newbie

Profile Information

  • Location
    California
  1. Thank you, that does the job! I really appreciate the fast and useful answers on this forum.
  2. These work: (sorry about the lack of indents, result of copy/paste) //set up event handlers//change background color on element mouseoverfor(i = 0; i < numTop; i++){ for(n = 0; n < numItems; n++){ items[n].onmouseover = function(){ this.style.backgroundColor = "#CCCCCC"; } items[n].onmouseout = function(){ this.style.backgroundColor = "#FFFF00"; } } //change visibility on element mouseover drop.onmouseover = function(){ this.style.visibility = "visible"; } drop.onmouseout = function(){ this.style.visibility = "hidden"; }} And these work: menu[0].onmouseover = function(){ drop[0].style.visibility = "visible"; } menu[1].onmouseover = function(){ drop[1].style.visibility = "visible"; } menu[2].onmouseover = function(){ drop[2].style.visibility = "visible"; } menu[0].onmouseout = function(){ drop[0].style.visibility = "hidden"; } menu[1].onmouseout = function(){ drop[1].style.visibility = "hidden"; } menu[2].onmouseout = function(){ drop[2].style.visibility = "hidden"; } So Why Doesn't this work??? for(i = 0; i < numTop; i++){ menu.onmouseover = function(){ drop.style.visibility = "visible"; } menu.onmouseout = function(){ drop.style.visibility = "hidden"; }}Firebug says drop is undefined
  3. I've never had validation problems with embedded JavaScript. Example... this validates (sorry about the formatting, it lost something in the cut/paste) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Knock Knock Joke</title></head><body><script type="text/javascript">//Begin the first jokeresponse = window.prompt("Knock Knock!", "Who is there?");//Analyze the player's inputif (response == "Who is there?") { //Validate player inputresponse = window.prompt("Orange.", "Orange who?");if (response == "Orange who?") { //Validate player inputwindow.alert("Banana.");}}//Begin the second jokeresponse = window.prompt("Knock Knock!", "Who is there?");//Analyze the player's inputif (response == "Who is there?") { //Validate player inputresponse = window.prompt("Orange.", "Orange who?");if (response == "Orange who?") { //Validate player inputwindow.alert("Banana.");}}//Begin the third jokeresponse = window.prompt("Knock Knock!", "Who is there?");//Analyze the player's inputif (response == "Who is there?") { //Validate player inputresponse = window.prompt("Orange.", "Orange who?");if (response == "Orange who?") { //Validate player inputwindow.alert("Orange you glad I did not say banana?");}}</script></body></html>
  4. I've been designing and maintaining small websites for non-profit organizations for about 6 years. The doctypes range from HTML 4.01 Transitional to XHTML1.1. I thought I was "doing the right thing" by going to XHTML and making sure all web pages passed the W3C validation test. But now I read that XHTML was a branch in a different direction and HTML5 is the way things will go in the future. I realize that HTML5 is not cooked yet however, it is a super-set of HTML 4.01. Should I abandon XHTML and go to HTML5 while staying away from features that are not supported by older browsers? It nicely removes a bit of HTML boilerplate that really isn't need for compatibility with older browsers. Perhaps I should go to HTML 4.01 Strict in preparation for the eventual move to HTML5 and its similarity to XHTML1.1. I realize the choice won't really make much difference in the code. I just like to comply with "standards" (which we carefully call "recommendations") and learn their rules. Your thoughts on this matter would be appreciated.
  5. Thanks for the reply. Yes, I realize that XMLHttpRequest is a problem prior to IE7. I hadn't thought about the original installations of XP being IE6. My websites (non-profit organizations) do get occasional hits from IE6, generally much less than 1%. So I'll not worry about language and hiding but keep in mind the need to take care of XMLHttpRequest if I do a website where IE6 may be important.
  6. How important is to code for old browser compatibility? I have experimented with eliminating the following and found no problems with IE7+ (IE version 7 introduced in 2006), all versions of Firefox, Safari, and Chrome. 1) language = "javascript" 2) All the code relating to XMLHttpRequest just use Request = new XMLHttpRequest() for all browsers tested. 3) <!-- Start hiding JavaScript statements // End hiding JavaScript statements --> There may be some more sophisticated JavaScript code examples that do need some special browser compatibility coding. I would be interested to know what they are. However, it seems the three listed above could just be eliminated.
  7. That sounds reasonable. However, I don't understand why most tutorials/books "teach" var myArray = new Array(); yet the two code checkers absolutely insist you use [ ].
  8. JShint.com and JSlint.com say that an array should be declared as var myArray = []; not as var myArray = new Array(); which is shown on most web resources and published books. What is correct and why?
×
×
  • Create New...