|
-
Feb 22nd, 2001, 04:43 AM
#1
Thread Starter
New Member
Hi,
Can you please tell me how can I catch "Exit" and "Back" events on a web page?
Thanks in advance.
-
Feb 22nd, 2001, 06:53 AM
#2
Fanatic Member
Bad news!
The biggest problem with browsers, is that you can't detect these events! IIS won't know if you have navigated to a different site, switched the PC off, or gone away from the PC for an hour!
You have to do a work around:
For the 'Back' event, you will have to hold a session variable, with the location of the current page. When another of your pages is entered via the back button (or shift + left arrow) then you read the session variable and act accordingly; Redirect, Alert etc.
Alternatively, you can use the request.servervariables("HTTP_REFERER") to determine where the user navigated from, so you can do the same.
For the 'Exit' event, you have no way of knowing. You can keep the last vistit time in a cookie, then read this on page delivery to know that a previous session was interupted, and handle as you require.
For more on these problems see www.4guysfromrolla.com wher thy have some nifty work arounds for these problems.
Good Luck
-
Feb 22nd, 2001, 07:29 AM
#3
Frenzied Member
To add to what Angry jet R R said above, you can detect when a user hits the back button or closes the browser with the "onUnload" event.
but you can't tell whether the user is going back or closing the browser.
onUnload is also fired on refeshing the page 
Code:
<body onUnload="alert('leaving the page')">
<body>
-
Feb 22nd, 2001, 08:19 AM
#4
Fanatic Member
Anagrams now eh Mark?
-
Feb 22nd, 2001, 08:31 AM
#5
Frenzied Member
Duh!
I just realised that it was your name spelt backwards after your name and not an anagram
Full list being sent by private message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|