By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Hitting Backspace to return to a previous page...

P: n/a

What event gets fire off?

I thought it might be an onLoad event, but that doesn't seem to be the
case.

(I have some variables displayed on my page that, upon a Backspace (or
even hitting the Back button, I suppose) doesn't reset to zero.)
Sep 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dave Christian wrote:
What event gets fire off?
Do not assume that whoever is reading your post can simultaneously see
(or remember) the subject.

I thought it might be an onLoad event, but that doesn't seem to be the
case.

(I have some variables displayed on my page that, upon a Backspace (or
even hitting the Back button, I suppose) doesn't reset to zero.)

I guess you mean is an onload event triggered in a page visited using
'backspace'. That may depend on the browser and possibly its configuration.

Firefox 1.0.6 and IE 6 seems to run onload whenever the page is visited
regardless how it is arrived at - by link, back button, alt+left arrow,
backspace, etc.

But I seem to remember that wasn't always the case in all versions.

window.onload is part of DOM 0, so there is no public specification of
how it should work.
Mozilla documentation states:

"The load event is fired at the end of the document loading process.
At this point, all of the objects in the document are in the DOM."

<URL:http://www.mozilla.org/docs/dom/domref/dom_window_ref63.html#1018577>

Microsoft says::

"To invoke: Load the persistent Web page from a favorite or shortcut
or through an Internet address."

<URL:http://msdn.microsoft.com/workshop/author/behaviors/reference/events/onload_1.asp>

--
Rob
Sep 22 '05 #2

P: n/a
I doubt any events actually get triggered as you enter the "old" page
again via back/backspace, because the browser most likely just displays
the cached version.
This is an issue which bugs webprogrammers all over the world, because
it poses some annoyances - especially with unexperienced web users -
which needs to be taken care of.

There are some tags you can write on the top of your page (expires and
no-cache etc) to try and force the browser to reload the page content
each time, but they don't work 100%. There are also other tricks which
can be used, but I've yet to find a 100% solution, but I'd advice you
to do a search for avoiding cahcing in the browser, and you'll see it
is quite discussed subject.

Sep 22 '05 #3

P: n/a
On IE 5-6, onload() always gets fired when you back-button to a page.
Also, onBeforeUnload() and onUnload() always get called on the page
you are coming from.

If you want to make sure variables are set to 0, initialize them in the
onload() of the page. Quite often, developers have the opposite
problem. They want variables be the same as the user left them. Form
fields will remain the same unless you initialize them in onLoad.

Works exactly the same in Firefox but does NOT in Opera. This may
explain the "speed" of Opera (they do no reload the DOM I guess) but in
my opinion, makes it deficient.

Sep 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.