473,386 Members | 1,758 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,386 software developers and data experts.

how to detect if user is at the last page of the history stack

when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?

Herc
--
I call3d this fugly and I'm proud www.supernerd.com.au/~gray77/kath1.jpg
Aug 22 '05 #1
12 3336
|-|erc said the following on 8/21/2005 10:10 PM:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?


No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 22 '05 #2
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:10 PM:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?


No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?


windows.history.length will tell me how many sites are in your queue, so
you are wrong.

FORM --- submit ---> PAGE 2 [click Back to edit]

When you click back (from my own page again), the form data is still there
and you can edit it. But the javascript variables are reset so I need to
reinitialise them using data from the form.

Herc

Aug 22 '05 #3
|-|erc wrote:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?


Seeing that some browsers cache the DOM and others do not, I doubt any
general solution is even possible.

--
John W. Kennedy
"Never try to take over the international economy based on a radical
feminist agenda if you're not sure your leader isn't a transvestite."
-- David Misch: "She-Spies", "While You Were Out"
Aug 22 '05 #4
|-|erc wrote:
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:10 PM:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?
No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?

windows.history.length will tell me how many sites are in your queue, so
you are wrong.


The reply was in regard to determining if the forward button is enabled
or not. How does the history length tell you that?

Or are you saying that it *is* your business where Randy came from?

FORM --- submit ---> PAGE 2 [click Back to edit]

When you click back (from my own page again), the form data is still there
and you can edit it.
Are you using your back button or the browsers? If it's yours, then you
can attempt to do what you like by posting data to the server but if
it's the browser back button, then some browsers retain the values and
others don't.
But the javascript variables are reset so I need to
reinitialise them using data from the form.


Then (attempt) to do so onload and expect to fail some of the time.

--
Rob
Aug 22 '05 #5
"John W. Kennedy" <jw*****@attglobal.net> wrote in
|-|erc wrote:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?


Seeing that some browsers cache the DOM and others do not, I doubt any
general solution is even possible.


so there's nothing like windows.history.length
but it tells you how far through the history you are?

say I wanted to make my own fast forward and fast back buttons.
go +10 or go -10 pages, but when you're near the ends, it changes to +2
or -2 pages.

That's impossible because you have no idea where in the history stack you
are??

Herc

Aug 22 '05 #6
"RobG" <rg***@iinet.net.au> wrote in
|-|erc wrote:
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:10 PM:

when a user clicks back to get to my site, I want it to run a javascriptfunction.

can you detect when the FORWARD button is greyed out?

No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?

windows.history.length will tell me how many sites are in your queue, so you are wrong.


The reply was in regard to determining if the forward button is enabled
or not. How does the history length tell you that?

Or are you saying that it *is* your business where Randy came from?


I'm saying

"its none of you business where I came from or where I am going" is not
true,

because I can easily tell how many sites you've been to.
What I'm asking for is whether some of those are ahead of me in the history.


FORM --- submit ---> PAGE 2 [click Back to edit]

When you click back (from my own page again), the form data is still there and you can edit it.


Are you using your back button or the browsers? If it's yours, then you
can attempt to do what you like by posting data to the server but if
it's the browser back button, then some browsers retain the values and
others don't.
But the javascript variables are reset so I need to
reinitialise them using data from the form.


Then (attempt) to do so onload and expect to fail some of the time.


I get the default form values when I tried that... not onload but directly
parsed, code not contained in a function body. Onload may make a
difference.... just a pain its in my header file.

Herc

Aug 22 '05 #7
|-|erc wrote:
"RobG" <rg***@iinet.net.au> wrote in

[...]

Are you using your back button or the browsers? If it's yours, then you
can attempt to do what you like by posting data to the server but if
it's the browser back button, then some browsers retain the values and
others don't.

But the javascript variables are reset so I need to
reinitialise them using data from the form.


Then (attempt) to do so onload and expect to fail some of the time.

I get the default form values when I tried that... not onload but directly
parsed, code not contained in a function body. Onload may make a
difference.... just a pain its in my header file.


Try the following:

<body onload="alert(document.formA.elementA.value);">
<form name="formA">
<input type="text" value="fred" name="elementA">
</form>
</body>

In both IE and Firefox the following behaviour is observed:

1. On initial load, get an alert with 'fred'.
2. Change the value to 'sue', click reload or ctrl+R, get 'sue'.
3. Navigate to another site, press browser 'back' button, get 'sue'.
4. Click in address bar, press enter, get 'fred'.

If you run the script after the form but before onload, you will get the
default values, not the 'current' ones. It seems that the browsers are
loading the page, then looking at the cache to replace form values, then
running onload.

--
Rob
Aug 22 '05 #8
"RobG" <rg***@iinet.net.au> wrote in ...
|-|erc wrote:
"RobG" <rg***@iinet.net.au> wrote in

[...]

Are you using your back button or the browsers? If it's yours, then you
can attempt to do what you like by posting data to the server but if
it's the browser back button, then some browsers retain the values and
others don't.
But the javascript variables are reset so I need to
reinitialise them using data from the form.

Then (attempt) to do so onload and expect to fail some of the time.

I get the default form values when I tried that... not onload but directly parsed, code not contained in a function body. Onload may make a
difference.... just a pain its in my header file.


Try the following:

<body onload="alert(document.formA.elementA.value);">
<form name="formA">
<input type="text" value="fred" name="elementA">
</form>
</body>

In both IE and Firefox the following behaviour is observed:

1. On initial load, get an alert with 'fred'.
2. Change the value to 'sue', click reload or ctrl+R, get 'sue'.
3. Navigate to another site, press browser 'back' button, get 'sue'.
4. Click in address bar, press enter, get 'fred'.

If you run the script after the form but before onload, you will get the
default values, not the 'current' ones. It seems that the browsers are
loading the page, then looking at the cache to replace form values, then
running onload.


Right, I thought that would be a longshot, its strange when the form has SUE
right in front of you and the alert is giving you FRED! I'll just use
onload like I should have.

Herc

Aug 22 '05 #9
|-|erc wrote:
"John W. Kennedy" <jw*****@attglobal.net> wrote in
|-|erc wrote:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?
Seeing that some browsers cache the DOM and others do not, I doubt any
general solution is even possible.

so there's nothing like windows.history.length
but it tells you how far through the history you are?


it's 'window.history', there is no 's' on the end.
say I wanted to make my own fast forward and fast back buttons.
go +10 or go -10 pages, but when you're near the ends, it changes to +2
or -2 pages.

That's impossible because you have no idea where in the history stack you
are??


RTFM. Pay particular attention to the statement "There is no public
standard that applies to this object":

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_history.asp>
--
Rob
Aug 22 '05 #10
|-|erc said the following on 8/21/2005 10:31 PM:
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:10 PM:
when a user clicks back to get to my site, I want it to run a javascript
function.

can you detect when the FORWARD button is greyed out?


No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?

windows.history.length will tell me how many sites are in your queue, so
you are wrong.

FORM --- submit ---> PAGE 2 [click Back to edit]

When you click back (from my own page again), the form data is still there
and you can edit it. But the javascript variables are reset so I need to
reinitialise them using data from the form.


That does not tell you:

1) How many sites *before* your site.
2) How many sites *after* your site.
3) What and where I was.

What's in my history trail is none of your business.

But to solve your problem, onload of the page, check your variables and
your forms and act accordingly. Then, forget about my history trail
because it won't matter.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 22 '05 #11
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:31 PM:
"Randy Webb" <Hi************@aol.com> wrote in ...
|-|erc said the following on 8/21/2005 10:10 PM:

when a user clicks back to get to my site, I want it to run a javascriptfunction.

can you detect when the FORWARD button is greyed out?

No. It is none of your business where I came from or where I am going.

Besides, what difference does it make?

windows.history.length will tell me how many sites are in your queue, so you are wrong.

FORM --- submit ---> PAGE 2 [click Back to edit]

When you click back (from my own page again), the form data is still there and you can edit it. But the javascript variables are reset so I need to reinitialise them using data from the form.


That does not tell you:

1) How many sites *before* your site.
2) How many sites *after* your site.
3) What and where I was.

What's in my history trail is none of your business.


It tells you "how many sites are in your history trail" so your deduction is
flawed.
I can put up a page "BEEN TO 250 SITES TODAY ALREADY.... TIRED OF SURFING
YET?"
or "JUST STARTING ON THE COMPUTER TODAY... BEEN TO A HALF DOZEN SITES?"

Herc

Aug 22 '05 #12
|-|erc said the following on 8/22/2005 7:49 PM:
"Randy Webb" <Hi************@aol.com> wrote in ...

<snip>

That does not tell you:

1) How many sites *before* your site.
2) How many sites *after* your site.
3) What and where I was.

What's in my history trail is none of your business.

It tells you "how many sites are in your history trail" so your deduction is
flawed.


No, your interpretation of my deduction is flawed. It will NOT tell you
where you are in the stack, only that you are in the stack and among X
number of pages. The fact that you think that is any of your business
also shows the fallacy in your thinking process.

I can put up a page "BEEN TO 250 SITES TODAY ALREADY.... TIRED OF SURFING
YET?"
I bet that would go over well..... Even though it isn't true. The
appropriate statement would be more like "According to your history
trail, you have visited J number of sites since your cache/history were
last cleared"/
or "JUST STARTING ON THE COMPUTER TODAY... BEEN TO A HALF DOZEN SITES?"


"Just started since clearing your history....."

Try this test:

Open the browser. In your case, use IE since it gives the history.length.

Navigate 200 or so pages.
Clear the history trail.
Close the browser.
Reopen the browser.
Open your "infallibly stupid page" that tells how many sites you have
been on.

How many does it show?

And then, explain if you have access to my history trail, why you can't
tell me whether the back or forward buttons or greyed or not, because
you can't. Its none of your business.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 23 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not...
6
by: Adam Warner | last post by:
Hi all, Is this a (C99) portable way to detect whether the C stack grows upwards (1) or downwards (-1)? #include <stdio.h> int stack_direction=0; void detect_stack_direction(void *...
2
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
8
by: Luke Matuszewski | last post by:
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg. function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can...
3
by: Niall | last post by:
When I say 'last', I mean (eg.) the 100th item in a 100-item history list, *not* the immediately previous one! The problem is, the history.go() method only allows *relative* movement through...
5
by: Phil | last post by:
What methods do we have of collecting information about browsing history? We would like to see the last few links that a client followed, prior to entering our site. I thought $_SERVER object...
4
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it...
5
by: =?Utf-8?B?QW5keQ==?= | last post by:
As per the question really. Not trying to stop them leaving, but just detect WHEN they leave the site
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.