Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8684 closed bug (invalid)

Back button doesn't trigger $(window).load() in Firefox on jQuery >= 1.4

Reported by: st.dave@… Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.4
Keywords: Cc:
Blocked by: Blocking:

Description

Using a version of jQuery later than 1.3.2, the $(window).load() event isn't fired when you come to a page via the back button. It fires correctly on the inital page load, but subsequent visits via the browser history do not trigger the event.

The bug appears in Firefox 4.0 on Windows, Firefox 3.6.13 on Red Hat Linux, Safari 5.0.3 for Windows and Mac OS X, and Opera 11.01 on Windows. I cannot reproduce it in Internet Explorer 8.0 or Chrome 10.0.648.133 for Windows.

I have created a simple webpage that demonstrates the bug using various versions on jQuery from 1.2 - 1.5.

Reproducing

  1. Open a webpage that has an event fire on $(window).load()
  2. Click a link to navigate to another page.
  3. Click the back button to return to the first page.

Observed Behavior: - The $(window).load() event does not fire when the original page is accessed via the back button.

Expected Behavior: - The $(window).load() event should fire when the page is accessed this way.

Change History (2)

comment:1 Changed 9 years ago by john

Resolution: invalid
Status: newclosed

More information about this can be found here: https://developer.mozilla.org/en/using_firefox_1.5_caching#pageshow_event

If you wish to cause a page reload you can always just bind an event to window unload.

$(window).unload(function(){});

What's happening right now is the intended behavior of the browser.

comment:2 Changed 9 years ago by the_dent2001@…

Is there a cross-browser jQuery function for the desired behaviour?

Shouldn't $(window).load()'s behaviour be consistent cross-browser? document.ready behaves inconsistently too.

Note: See TracTickets for help on using tickets.