spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column11


Elements that Initiate Events

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

With Internet Explorer 4.0x, every HTML element on the page can be the source for a full set of mouse and keyboard events. For example, the following elements support the onmouseup event handler:

A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, document

Although Navigator 4.0x greatly expanded its set of elements that generate events, the selection is still much more limited. Not all elements can be the source of a mouse or keyboard event. For comparison, here's a list of the elements that support the onmouseup event handler in Navigator 4.0x:

A, AREA, button (a sub-element of INPUT), IMG, document

Needless to say, there are only several elements that accept the onmouseup event handler in Navigator 4.0x. There is obviously no way to specify an event handler for an element that doesn't support it. Since Internet Explorer 4.0x normally features much more elements that support a given event handler, you should only use those that are also supported by Navigator 4.0x when writing a cross-browser script. In any case, if you add an event handler to an element that doesn't support that type of event handler, it has no effect. Regardless of whether you specify the event handler as a property or as an HTML attribute, the browser does not generate an error (because HTML never causes explicit errors, and adding a new property to an existing object is a legal JavaScript operation). For example, Navigator 4.0x ignores the following event handler specification, whereas Internet Explorer 4.0x supports it:

<P onClick="alert('This only works with Internet Explorer 4.0x.')"></P>

The P element in Navigator 4.0x does not support any event handlers, so this definition does not work. In fact, you can find out for yourself by clicking these words, because we have specified an onclick event handler for this paragraph. The alert dialog box should pop up if you are running Internet Explorer 4.0x. Otherwise nothing occurs when you click the paragraph.

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: January 13, 1998
Revised: January 14, 1998

URL: http://www.webreference.com/js/column11/elements.html