Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours

By Michael Moncur

Q&A

Q1:

I created an onMouseOver event handler for rollovers, and it works in Internet Explorer but not Netscape. What's wrong?

A1:

This is probably because you used the onMouseOver handler in the <img> tag. This is supported only by Internet Explorer. For Netscape, you need to make the image a link and use event handlers in the <a> tag. (This will also work in Internet Explorer.)

Q2:

Can I use rollovers in an image map?

A2:

No, you'll need to replace the entire map image to do this. Usually, it's easier and faster to divide the map image into a number of sections and use those as the rollovers.

Q3:

JavaScript animation seems a bit basic. Is there a way to do more complex or interactive animation?

A3:

Not in JavaScript. For these purposes, you may want to look into using Java or Macromedia's Flash. See this URL for more information about Flash: http://www.macromedia.com/software/flash/.

Q4:

I created a JavaScript program on a page with images, and my event handlers don't seem to be working. What's wrong?

A4:

JavaScript requires you to use HEIGHT and WIDTH attributes on all <img> tags. Adding them will most likely make the event handlers work properly. See Hour 17, "Debugging JavaScript Applications," for other debugging techniques.

Share ThisShare This

Informit Network