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.
Looking For A New Job?
- Full Stack Angular/Rails Engineer @ newly funded Health-IT startup at Dorsata
- Part-time remote DBA needed at Bridge
- Senior Developer Wanted for International Cloud Company at Giva, Inc.
- ColdFusion Developer - jQuery, PrimeUI, ORACLE DB at ComSpec International, Inc.
- Jr. ColdFusion Developer - Full Time / Telecommuting is ok. at InterCoastal Net Designs
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.
good catch on reading this.
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.
It's a feature, not a bug: https://bugzilla.mozilla.org/show_bug.cgi?id=109463
FireFox implemented this to copy IE5/6's behavior.