onload event only happens on browser back if there is an onunload handler

RESOLVED INVALID

Status

()

Core
DOM
RESOLVED INVALID
11 years ago
11 years ago

People

(Reporter: William Bardwell, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2pre) Gecko/20070108 Minefield/3.0a2pre

If I have a document with JavaScript like the following:
window.onload =
function()
{
    alert("calling on-load");
};

If I browse that page, the code fires, if I then browse to a new page, and then hit browser back, I find that that code only happens if I add code to set an onunload handler (even an empty one.)

Reproducible: Always

Steps to Reproduce:
1. See above happens in 2.0, Gran Paradiso and last nights minefield
2.
3.
Actual Results:  
See above, onload only happens on initial load, and not on browser back to a page, unless you also have an onunload handler.

Expected Results:  
window.onload =
function()
{
    alert("calling on-load");
};

Should be enough to be called on initial load and browser back.  But instead I need to add the below, which should have no effect.

window.onunload =
function()
{
};
Assignee: general → general
Component: JavaScript Engine → DOM
QA Contact: general → ian
This is invalid. You should use the pagehide/pageshow event if you want your handlers to be fired on back/forward navigation. See http://developer.mozilla.org/en/docs/Using_Firefox_1.5_caching .
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.