I need to put an image that acts as a button which takes you back one screen. I’ve written the following for going back to the previous screen:
<input type="image" src="../../img/button_cancel_gray.gif" type="button" onclick="history.go(-1);"/>
Which works, except it’s also submitting the form. I need it to prevent submitting the form.
For an alternative, I’ve tried to wrap the image inside a button.
This one works too but now it shows the default border of the button outside the image, which makes it look ugly.
So how do you make an image act as a button that runs onclick but not submit the form?
Make the onclick event return false, which will prevent form from submitting.