| home / experts / dhtml / column12 |
|

Click the triangles to expand the headings: (IE4 only)
World Wide Web Consortium (W3C)
Netscape
In the first example, above, the image is contained in a link, as our first example on the previous page:
The expandIt() function is modified to swap images, to reflect the expanded/collapsed state of the element:
Notice that the image to be swapped is identified as event.srcElement. That is, the element that received the event (click). Although the click was meant for the link (A) element, Explorer's bottom-up approach to event handling identifies the IMG as the event source element, and since this element does not define an action for the event, it is passed up to the A.
Explorer event handling is discussed in Dynamic Images, in the context of the column examples, and generally, in Doc JavaScript's The Internet Explorer Event Model.
The second example avoids the link, and uses onClick as an event handler of IMG.
Notes: The ALT attribute is displayed by both DHTML browsers when the mouse is over the image. This new behaviour makes ALT a "hint" or "extra info" attribute as well as a label for non-graphical or images-off browsers. Use it to provide information on links or click actions.
When Navigator 4 parses the STYLE attribute in the IMG tag, it renders the IMG and possibly succeding elements incorrectly. Although cursor:hand is a helpful property here, it should be used only in Explorer-specific applications.
The complete Explorer code is repeated in our first code page.
I know, it's not challenging. The same, however, cannot be said for the Navigator version!
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.
Created: Jan. 14, 1998
Revised: Jan. 18, 1998
URL: http://www.webreference.com/dhtml/column12/outIEtwo.html