There really ought to be a #DOM API that exposes the #UserAgent string in nicely tokenized form.

I guess browser people don't want to encourage browser detection, but it's not my fault their code has bugs I have to work around, and checking for a User-Agent token with regex isn't super reliable.

#webdev

@argv_minus_one there is an idea that you could often write some code to detect the bug before activating the work around, but personally I don't like that very much. The problem I have with it is that some bugs aren't detectable anyway and some bugs take a noticeable amount of cpu time and JS bytes to write a detector for and it seems to me very bad to punish all users for the foreseeable future with lots of code bloat for a browser bug that will hopefully be temporary.

@0x2ba22e11

The bug in this case is that, when the user clicks a link with a `click` event handler and then clicks the Back button, the event handler is executed *twice*: first before switching to the new page, then again after going back.

Only happens if the bfcache is enabled. Workaround: listen for `unload` events; that has the side effect of disabling the bfcache.

@0x2ba22e11

As far as I know, there's no way for scripts to detect that this is happening. As far as the script knows, it has only been executed once. All state is restored to how it was *before* the `click` event handler was executed the first time, including any variables I might set up to count click events, timers that must elapse before processing another click event, etc.

@argv_minus_one might be possible by fucking around with iframes but not worth it.

@0x2ba22e11

Hmm.

In my 20s, I probably would have taken that as a challenge and given it a try.

But I'm not in my 20s any more. 😛 Like you said, not worth it. Easier to just disable the bfcache on Gecko and be done with it.