devxlogo

Making the Image OnClick Work in Both Browsers

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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist