Ticket #12547 (closed bug: notabug)
window.onbeforeunload fires twice with IE8 under special circumstances
| Reported by: | christoph.strasser@… | Owned by: | christoph.strasser@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.8.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The event window.onbeforeunload fires twice when we click a button via Javascript.
Problem-reproduction: http://194.48.48.79/jQueryBugs/ZZZ_jQueryOnBeforeUnloadFiresTwice_IE8.html
It happens, when clicking "click button via JavaScript" or "click dynamic generated button".
The problem occurs with IE8, it does not occure with Firefox (15) and Chrome (21).
It worked fine up to jQuery 1.6.4, since jQuery 1.7 (tested up to 1.8.1) it is broken.
Change History
comment:1 Changed 8 months ago by dmethvin
- Owner set to christoph.strasser@…
- Status changed from new to pending
comment:2 Changed 8 months ago by christoph.strasser@…
- Status changed from pending to new
Added two additional test cases to the existing sample. It does not matter whether you use inline handlers or not. I´m able to work around the problem by clicking the other button without jquery (=only using "classic" javascript). The problem exists also with IE9. I made all my tests with Windows 7.
comment:3 Changed 8 months ago by christoph.strasser@…
Made a mistake within the extended sample. My last comment was wrong, will provide an update...
comment:4 Changed 8 months ago by christoph.strasser@…
After some more test cases, i think this problem is not related to jQuery.
http://194.48.48.79/jQueryBugs/ZZZ_jQueryOnBeforeUnloadFiresTwice_IE8_withoutJQuery.html
http://194.48.48.79/jQueryBugs/ZZZ_jQueryOnBeforeUnloadFiresTwice_IE8_withoutJQuery_withAlerts.html
http://194.48.48.79/jQueryBugs/ZZZ_jQueryOnBeforeUnloadFiresTwice_IE8.html
At this point in time i think i was able to work around this IE-behavior successful.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I believe this is because of the use of inline handlers. Can you create a test case that does not use them for comparison? In oldIE there are situations where inline handlers are executed twice, and we're unable to fix that.