473,406 Members | 2,549 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,406 software developers and data experts.

Detecting leave page

Hello,

im making a forum and stumbled upon the following problem.
i want to detect when a user leaves the page, when the user leaves the page i want to null a Session variable.
I am doing this in the Admin control panel, this will have an extra login which will create an AdminAuth Session variable. when the user navigates off the page it will remove that variable. The page uses Webcontrols to display various aspects thus will be refreshed.

any help will be appreciated

Greetz
- Mega
Jul 27 '09 #1
2 9276
Frinavale
9,735 Expert Mod 8TB
Hi Mega,

This is going to involve using JavaScript. The onbeforeunload JavaScript event is executed before the page is unloaded.

This event occurs if the user is leaving the page, closing the browser, or the page is preforming a PostBack to the server. So, this means that you're going to have to write a bit of JavaScript that registers all of the controls on the page in order to determine whether or not the page is posting back (since you don't want to log out the user at that point). By "registering" all of the controls, I mean you have to ensure that they set some variable to true if the page is unloading because of a PostBack.

Read over the onbeforeunload event (note that it's not supported in opera), and then check out this post.


Cheers!

-Frinny
Jul 27 '09 #2
hmmm, the PostBack gave me an idea.
to check for the variable on initial load, and then destroy it. skipping this check on postback.
if that doesnt work i might have to resort to JavaScript (which i dont really have any knowledge of)

Thanks for the reply
Jul 27 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: G | last post by:
Hello, I want to launch a pop-under survey when a user leaves my page by closing the window, but NOT by leaving the page via a hyperlink or form submission. Is this easy to accomplish with...
11
by: Dag Sunde | last post by:
We have this web-app that requires Javascript to be enabled in the UA (this is okay'ed by our customer). Now I want to make a "pre" page before the login screen, informing the user that he/she...
2
by: epigram | last post by:
I have a form on a web page that contains several textbox controls (i.e. input type="text") and a checkbox. As soon as the text changes, in only a subset of these textbox controls, I want to...
79
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the...
3
by: Greg | last post by:
The LostFocus event of datagrids is fired when the focus is added to a cell. How do you go about detecting it when the control as a whole has lost focus to another control? Slightly confused by...
1
by: Jason | last post by:
I am creating a Comet/Ajax chatroom system. When people go to the page, it will add them to the list of people in the room via window.onload. When they leave, disconnect, go to another page, or...
3
jhardman
by: jhardman | last post by:
I have an old site built with frames, and I plan to leave it in frames for now. The problem is that occasionally I find links (from outside) lead me to just the content frame which means most of the...
9
by: raknin | last post by:
Hi, I want to detect when the user close a window through the X button or ALT-F4 or when the user go to another page and leave my page. I try to use the onuload and on unloadbeore but it...
4
by: daveh551 | last post by:
Okay, I feel like this is probably a stupid question, but... I have accessed sites that are pushing some scam that, when you go to leave the page it will pop up a box saying, "No, don't go, let...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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.