File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes onClick() doesn't work for Image, any work around!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "onClick() doesn Watch "onClick() doesn New topic
Author

onClick() doesn't work for Image, any work around!!

Kanan Jariwala
Greenhorn

Joined: Jun 22, 2000
Posts: 17
Hi all,
In my requirement, i have more than one images(that act like buttons), when i click on any of the imgages,
1)onClick should get invoked
2)Within the onClick()Script some hidden Input Types are set dynamically
3)the form is then submitted.
Note: onClick() works in IE , but not in Netscape.
I am looking out for a solution that will work in both
thanks
kanan
Sid Sharama
Greenhorn

Joined: Feb 06, 2005
Posts: 11
hi,
make image an href like
<a href="some action" onClick='dosomejavascript()'><img src='pic.gif'></a>
it should work fine.in javascript you can even change the image
by specifying a new src.

regards,
sri
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
You have to be a little careful with making an image into a link. Some browsers will link to the specified URL as well as running the onClick.
The best solution I have found is to make the image into a link,
but link to a "javascript" URL. For example:


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onClick() doesn't work for Image, any work around!!
 
Similar Threads
tracking links in a db
Using onclick and ondblclick with setTimeout
Page displaying in IE6 and older versions but not in Higher versions, chrome and firefox also.
Getting "Unspecified" Java Script Error When trying to save a File.
Cannot find the problem in the code