|
Tangled web
|
|
|
Wednesday, March 27, 2002 Event handlers In a letter to the HWG-Basics list today, I saw the information that html includes many event handling attributes such as onClick() which I assumed were javascript. Apparently not! Thanks to Bert Doorn for the clarification (I was not the only one laboring under the misapprehension!) OnClick is an HTML attribute (or XHTML if you put it in all lower case). It's not JavaScript. Bert directed the questioner to http://www.w3.org/TR/html401/interact/scripts.html#adef-onclick for the full list of html atributes that resemble (to the untutored, I guess) javascript. In fact these attributes are heavaily used by javascript-- and other scripts too -- but are not themselves script parts. He showed sample code for a link to open information in a new window that works even if the use has javascript turned of in their browser; if they have javascript, however, it is possible for the designer to size that new window to fit the (small) content. Without javascript the link reads like this: <a href="thepageurl.html" target="_blank">Click Here </a>
With javascripit, it can be written like this to size the window: First, in the head section: function Genie(theURL)
{ var theWindow = window.open(theURL,"","width=300,height=200") return false; } Second, where the link is to go in the body: <a href="JavaScript:Genie('thepageurl.html');">Click Here<./a>
These can be combined into one script to take care of javascript enabled and disabled browsers: <a href="thepageurl.html" target="_blank" onclick="return false;
Genie('thepageurl.html');">Click Here</a> |
|