Skip to main content
Ben Nadel at cf.Objective() 2014 (Bloomington, MN) with: Jeff McDowell and Joel Hill and Jonathan Rowny and Shawn Grigson and Jonathan Dowdle and Matt Vickers and Christian Ready and Asher Snyder and Clark Valberg and Oscar Arevalo and David Bainbridge and Josh Siok
Ben Nadel at cf.Objective() 2014 (Bloomington, MN) with: Jeff McDowell@jeff_s_mcdowell ) , Joel Hill@Jiggidyuo ) , Jonathan Rowny@jrowny ) , Shawn Grigson@shawngrig ) , Jonathan Dowdle@jdowdle ) , Matt Vickers@envex ) , Christian Ready@christianready ) , Asher Snyder@ashyboy ) , Clark Valberg@clarkvalberg ) , Oscar Arevalo@oarevalo ) , David Bainbridge ( @redwhitepine ) , and Josh Siok@siok )

FireFox Fires OnClick Handler for Submit Buttons

By on

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:

<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.

Want to use code from this post? Check out the license.

Reader Comments

1 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

1 Comments

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.

1 Comments

You too? My friend just thought of that also. He mentioned that we could get a code on that. And you have one. That's awesome. Having Mozilla Firefox is way better than the IE, I swear. For all the add-ons, Firefox has it.