spacer

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

home / experts / javascript / column4


Event Handlers in Internet Explorer 4.0

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

In Internet Explorer 4.0, the number of event-generating HTML elements have been greatly expanded. Previously, only a small set of HTML elements could generate events: anchors, image maps, form elements, applets, and objects. With Internet Explorer 4.0, every HTML element on a page can generate a full set of mouse and keyboard events. For example, each element on a page features an onMouseOver event handler. Keep in mind that Netscape Navigator 4.0x does not support this feature, so people using that browser cannot benefit from it. However, why not let Explorer 4.0 users enjoy the power of their browser? Here is a set of common events that every HTML element generates in Internet Explorer 4.0:

  • onMouseOver
  • onMouseOut
  • onMouseDown
  • onMouseUp
  • onClick
  • onDblClick
  • onKeyPress
  • onKeyDown
  • onKeyUp

For more details on new event handlers in Internet Explorer 4.0x, be sure to look at Microsoft's official documentation.

If you're viewing this page with Internet Explorer 4.0, pass the mouse over these words. Explorer should generate a JavaScript alert. How did we do this? As a matter of fact, it's very simple. Since any HTML element supports the onMouseOver, we put one in a standard <FONT>...</FONT> definition, with no style add-ons. When you passed the mouse pointer over the surrounded text, the event was fired. We could have used any other set of HTML tags, including <SPAN>...</SPAN>, <H1>...</H1>, and <P>...</P>. Here's the exact code we used for the first sentence in this paragraph:

If you're viewing this page with Internet Explorer 4.0,
pass the <FONT onMouseOver="alert('Isn\'t this surprising?')">
mouse over these words</FONT>.

Since other browsers (such as Netscape Navigator 4.0- and Microsoft Internet Explorer 3.0-) don't recognize the onMouseOver event handler when placed in a <FONT>...</FONT> definition, they simply ignore it, like any other unsupported HTML tag or attribute. Thus, users running such browsers are not adversely affected. This is definitely a win-win situation! You can provide special effects for those who are using Internet Explorer 4.0+, without penalizing others.

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: October 9, 1997
Revised: December 4, 1997
URL: http://www.webreference.com/js/column4/events.html