Q&A
I noticed that the <img> tag in HTML can't have onMouseOver or onClick event handlers in some browsers. How can my scripts respond when the mouse moves over an image?
The easiest way to do this is to make the image a link by surrounding it with an <a> tag. You can include the BORDER=0 attribute to prevent the blue link border from being displayed around the image. You'll see an example of this in Hour 13.
My image rollovers using onMouseOver work perfectly in Internet Explorer, but not in Netscape. Why?
Re-read the previous answer, and check whether you've used an onMouseOver event for an <img> tag. This is supported by Internet Explorer and Netscape 6, but not by earlier versions of Netscape.
What happens if I define both onKeyDown and onKeyPress event handlers? Will they both be called when a key is pressed?
The onKeyDown event handler is called first. If it returns true, the onKeyPress event is called. Otherwise, no keypress event is generated.
When I use the onLoad event, my event handler sometimes executes before the page is done loading, or before some of the graphics. Is there a better way?
This is a bug in some older versions of JavaScript. One solution is to add a slight delay to your script using the setTimeout method. You'll learn how to use this method in Hour 11, "Using Windows and Frames."
When I try the descriptive links example in Netscape 6.2, the descriptions don't display. Why not?
At this writing, the latest version of Netscape 6 fails to display the descriptions if your link includes the HREF attribute. One way around this is to use an onClick event handler instead, as in <a onClick="location.href='newpage.html';">. This works, but Netscape doesn't display it in the correct link color.