Form submit button remains disabled when using Back button in Firefox
I'm using some jquery to disable a form submit button after it's been clicked to prevent accidental repeated clicking. This works fine 开发者_StackOverflow中文版in all browsers except Firefox. In Firefox if the user uses the browser Back button to go back to a page after the submit button disabling has occurred, the submit button is still disabled. Is there any solution to this problem?
Probably, you should add autocomplete="off" parameter to your form
<form autocomplete="off">
<input type="submit" />
</form>
$(document).ready(function() {
$('input[type=submit]', this).attr('disabled', false);
$('#myform').submit(function(){
$('input[type=submit]', this).attr('disabled', true);
});
});
Using jQuery, this will make the button not disabled upon using the back-button on the browser. Tested on FF 3.5.
If a browser has caching disabled, then the page will be reloaded as if nothing had happened (no button clicked).
If you want client side, you could use a cookie.
Now, if you have a a server side technology (PHP/Rails), then you could put the value in the session variable.
精彩评论