473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 12980
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eric Osman | last post by:
Hi, When I run the following html file on netscape, and the button is clicked, the new window pops BEHIND all my other windows. How can I easily fix this html file so the window comes up in...
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
1
by: Bryan | last post by:
When I leave a page that has a user control and press the back button on my browser I notice that the Page_Load event of the user control doesn't fire unless i do a refresh on the page. Is there a...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
2
by: Ersin Gençtürk | last post by:
I show errors as popup boxes via alert() but I write this scripts in header of html page.So if there is an error on the server side , in the next postback a popup shows the error via alert , this...
3
by: Vivek | last post by:
Hi all, I have a problem in my web-app wherein I need to get the latest page from server on clicking of back button.. I know that it can be done by preventing/disabling the cache in jsp as ...
6
by: lucyh3h | last post by:
Hi, In one of my pages, I use javascript (AJAX) to populate one mulitple select field based on user's click event on another control. I noticed that when I navigate back to this page by clicking...
4
by: John | last post by:
Hi everybody, for my web-application (it must currently work only under IE6) I have a servlet that intercepts user's HTTP GET requests for a typical search result page, which contains a paging...
0
acoder
by: acoder | last post by:
Problem onload and onunload events do not fire when going back, forward or refreshing the page Browser Opera Example Any code using onload or onunload, e.g. window.onload = init; where...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.