473,703 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3367
|-|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.javas cript 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*****@attglo bal.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.ne t.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.ne t.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
reinitiali se 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(d ocument.formA.e lementA.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.ne t.au> wrote in ...
|-|erc wrote:
"RobG" <rg***@iinet.ne t.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
reinitiali se 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(d ocument.formA.e lementA.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*****@attglo bal.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

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

Similar topics

15
7655
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 there at all? Any feedback would be helpful. Thanks! -Josh
6
2543
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 * stack_start) {
2
2259
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 link, I also register logoff time and update accordingly the logging history table. However user can simply close the browser without logoff, so his session was closed.
6
3739
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 user get used to click "enter" key to submit a form. How can I use "enter" key to submit/postback in ASP.NET. Thank, Guoqi Zheng
8
17375
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 detect the close of the browser window */ } if(window.event) { /* maybe via analyse of window.event object i can detect the close of the browser window */
3
2243
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 the history list. I need to go directly to the end -- an *absolute* movement -- and there doesn't appear to be any way of finding out the number of 'steps' that would require. Ideally, what I would use would be something of the form:
5
1989
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 might have something like this, but I haven't found any details, yet. Thanks for your ideas. Phil
4
7918
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 while he doesn't leave). I'm using the window.onunload event to trigger the unlocking of a page, but I don't want the page to be unlocked when a postback or a refresh occurs...I only want it when the user goes to another page or closes the...
5
2924
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
1
9017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4432
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3123
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2450
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2069
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.