469,366 Members | 2,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

back button and onload event

Consider this scenario..
I m on page "1.html" in IE(6) and click on href which takes me to
"2.html".
I press browser back button. Then "onload" method of 1.html is fired.

onload is not fired on back button in Firefox but IE does.

I want to distinguish between first load of the page and false "onload"
fired by back button.
How do i do this?

~Sunil

Jul 13 '06 #1
7 12665
I want to distinguish between first load of the page and false "onload"
fired by back button.
You could use the history.previous or history.next field to check what
page came before and after yours.

Greetings,
Vincent
Jul 13 '06 #2
Vincent van Beveren wrote:
I want to distinguish between first load of the page and false "onload"
fired by back button.

You could use the history.previous or history.next field to check what
page came before and after yours.
"if" a page (you can't know which one)

--
Bart

Jul 13 '06 #3
Vincent van Beveren wrote:
You could use the history.previous or history.next field
to check what page came before and after yours.
Not all browsers provide - history.previous/next - properties, but those
that do tend to throw exceptions if you try to read them with code
running on a public web site (as that would be a privacy/security
violation).

Richard.
Jul 13 '06 #4
probably the easiest would be to use a cookie.

window.onload = function () {

if (document.cookie && document.cookie.indexOf("loaded=true") >= 0)
return;

document.cookie = "loaded=true";

}

Jul 13 '06 #5
sunilp said the following on 7/13/2006 3:09 AM:
Consider this scenario..
I m on page "1.html" in IE(6) and click on href which takes me to
"2.html".
I press browser back button. Then "onload" method of 1.html is fired.

onload is not fired on back button in Firefox but IE does.

I want to distinguish between first load of the page and false "onload"
fired by back button.
How do i do this?
You can't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 13 '06 #6
Vincent van Beveren said the following on 7/13/2006 3:41 AM:
>I want to distinguish between first load of the page and false "onload"
fired by back button.

You could use the history.previous or history.next field to check what
page came before and after yours.
Oh? Do you have sample code that shows how to get entries in the history
trail?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 13 '06 #7
go*****@gmail.com said the following on 7/13/2006 10:38 AM:

Question: What's the easiest way to spot a Google Groups user?
Answer: I would tell you but I would have to quote it.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
probably the easiest would be to use a cookie.
No, that is not "probably the easiest" way.
window.onload = function () {

if (document.cookie && document.cookie.indexOf("loaded=true") >= 0)
return;

document.cookie = "loaded=true";

}
Did you test it?
P.S. Disable cookies and test your code......
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 13 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Eric Osman | last post: by
1 post views Thread by Bryan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.