FireFox Fires OnClick Handler for Submit Buttons
Posted May 15, 2006 at 12:22 PM
I just discovered something by accident in my code. It seems FireFox will trigger the onClick event for a submit button even if the FORM element is submitted via the Return Key:
Launch code in new window » Download code as text file »
- <input type="submit" value="Save" onclick="alert('This will fire in FireFox');" />
I think this is really cool, though not sure if it is a bug or a feature. Internet Explorer (IE) on the other hand, does not perform this action.
Download Code Snippet ZIP File
Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Newer Post
The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed
Older Post
Using Methods in Javascript Replace Method
Reader Comments
Hi...
I found your blog when i was searching on how to fix the 'onclick' event not firing in firefox...
And i think you just gave me the solution...haha
post a solution to following problem:
- if I have 3 buttons and 2 of them would have to do submit.
how would you handle it?
<input type="button" name="ask_later" value="Ask Me Later" OnClick="frmPreferences.submit();">
<input type="button" name="btnCancel" value="Cancel" OnClick="history.back()">
<input type="submit" name="btnSavePreferences" value="Save Preferences"></td>
I need on when user would click "ask me later" the cookie would be created. so I assume via submit - I wil lreload a page, and its be in the code to do it.




