Text Rollovers: Event Handlers in Internet Explorer 4.0 - Doc JavaScript
Event Handlers in Internet Explorer 4.0
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.
Created: October 9, 1997
Revised: December 4, 1997
URL: https://www.webreference.com/js/column4/events.html