Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with:

FireFox Fires OnClick Handler for Submit Buttons

By Ben Nadel 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.



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

Reply to this Comment

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.

Reply to this Comment

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.

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.