1

I'm having cross platform issues with Firefox and form submissions.

http://pastebin.com/BEFsBd8h

In the example, when the button is disabled and the page I'd directs to another location, firefox does keep the button disabled whereas other browsers do not.

I know I can use an onunload event to remove the disable attribute. But I'm wondering if there's another way. I've also tried by setting autocomplete off but alas it did not work

Reproduce bug:

 Use firefox
 Disable button
 Use sudo-submit
 Back button

The test button should still be disabled.

Huangism
  • 16,278
  • 7
  • 48
  • 74
kevinly24
  • 11
  • 3
  • 1
    possible duplicate of [Bug With Firefox - Disabled Attribute of Input Not Resetting When Refreshing](http://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing) – gpgekko Jul 14 '14 at 14:04
  • Not a duplicate: the bug is when I'm going back to the page. Not on refreshing – kevinly24 Jul 14 '14 at 14:07
  • 1
    http://madhatted.com/2013/6/16/you-do-not-understand-browser-history - it seems to be how Firefox decided to implement the Back button, it stores the whole DOM state and just load it again when you hit the Back button. – Luizgrs Jul 14 '14 at 14:11
  • So there is no clean way to fix this issue? – kevinly24 Jul 14 '14 at 15:03

1 Answers1

3

When Firefox traverses history, it will not always reload the page, but often will actually use a cached copy of the page with the same state from where you left it. So if a button was disabled when leaving it, then it will be disabled when "going back" and the page is still cached in the backward-forward-cache (bfcache).

Two options to deal with this:

  1. Implement either pageshow or pagehide events. E.g. you could reset the DOM state in pageshow.
  2. Implement handling of the unload event. This will disable the bfcache entirely, and therefore degrades performance, but is easier to do.

For more information, see the rather old, but still applicable "Using Firefox 1.5 caching" article.

nmaier
  • 32,336
  • 5
  • 63
  • 78