Making the Image OnClick Work in Both Browsers

Since the introduction of DHTML and client-side scripting, developing Internet applications can be a real challenge. If you don’t have the luxury of a “pure” Internet Explorer environment, there’s a good chance that onclick event you coded will not fire in Netscape. With Netscape, the image () tag does not recognize the onclick event the way that IE does. To get around this problem, you can add an AreaMap to the HTML. If the browser is IE, the onclick event will fire from the IMG object but ignores the AreaMap. On the flip side, Netscape will fire the HREF code and ignore the onclick of the image object:

 	

If you’re using Netscape, it will understand what to do with this line of code:

and will execute the procedure named “reqpswd()”. On the other hand, IE will respond to the onclick event and execute the same procedure. The end result is the same from the two different browsers. It also avoids having to put conditional statements in your HTML for browser checking.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: