View Full Version : browser connected or not?
07-05-2002, 05:10 AM
purpose: to detact if the browser is still active. once the browser is closed, do something such as pop-up window!!
2. also, is it possible to tell if the browser is closed down? ie, if the client close the browser, then do something.. (such as calling asp script or pop up a new window).
3. is there any way to know if the client browser is connected to the website? please advise :)
God bless you :0 hope that someone can advise and teach me how to detect if the browser is still connected.
07-05-2002, 06:46 PM
You can use setInterval() to execute a piece of script code on the browser repeatedly at some time interval:
//Call myRefresh() every 30 seconds (30,000 milliseconds).
You can't tell when a browser is closed however. HTTP is a stateless protocol and it doesn't depend on keeping an open connection.
When you load a web page, the browser makes a connection to the web server to request the file and download it. Once the file is downloaded, the connection is closed.
If you follow a link to another page, a new connection is created and again closed as soon as the data has been downloaded. The browser and server do not stay connected between these requests. Neither one has any way of knowing what the other may be doing between those requests.
Also, in general, the web server has no idea what requests are coming from what browser. That's what is meant by a stateless protocol. In order to track a particular user, cookies or query string data can be used to send identifying information back and forth between the browser and server with each request and download.
That still doesn't help a web server know when a user has gone to another site, closed the browser, lost their internet connection, turned off the computer, fallen asleep or whatever. A user may make another request or they may not.
Usually, when tracking users with cookies or whatever, a timeout scheme is used on the web server. If that user makes another request before the time expires, the countdown starts over. If not, the server just assumes the user is done and ends the session. That's pretty much how ASP sessions work.
07-08-2002, 03:52 AM
Thanks Brainjar :)
Thanks for your explanation. i had finally come to understand more about the web technology. However, in asp, we can use isConnectedAfter() to find out if the browser is still connected to the server-requested page.
...check if the browser is connected using isConnectedAfter(). else, ...
the example is not working. the above is just a sample, the question is :
Please advise, if only i could use them both together. then, it might solve my current problem. thanks :)
God bless yah
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.