views:

142

answers:

2
<form action="http://google.com"&gt;
  <input type="submit" onclick="javascript:this.disabled='disabled';return true">
</form>

It works in Firefox, but not in IE8, Safari (It should forward me to Google's site, it but doesn't happen.). Why?

+3  A: 

You don't need the javascript: pseudoprotocol. This should work:

onclick="this.disabled=true"

and you don't need to return true, that'll happen automatically.

Rafael
Did you try? Seems still not working.
wamp
+2  A: 

Try this instead:

<input type="submit" onclick="this.disabled='disabled';form.submit()">

Edit: Added form. as per wamp's comment.

Gert G
Do you know why `return true` doesn't work?
wamp
I'm not sure, but it seems to be something with IE's implementation of JavaScript.
Gert G
Probably more accurately, it's likely a problem with IE's implementation of the *DOM*. Or maybe this is relying on an extension, because I don't remember any global `submit` functions.
strager
In some cases, I need `form.submit()`, simply `submit` will get an error saying "Object expected",strange..
wamp
@strager,you are right,the global `submit` doesn't work in my application,but works in this simplified example,this is strange..
wamp
@wamp - `submit()` only worked when I tested it, but just to be on the safe side, I added the `form.` from your comment.
Gert G
@strager - I tested it in IE 8, Firefox and Iron. Anyway, I've changed the code in my example above.
Gert G