Web Analytics Made Easy -
StatCounter browser connected or not? - CodingForum


No announcement yet.

browser connected or not?

  • Filter
  • Time
  • Show
Clear All
new posts

  • browser connected or not?

    purpose: to detact if the browser is still active. once the browser is closed, do something such as pop-up window!!

    1. is it possible to write a javascript program that will act as a timer / reminder and refresh every 30 minutes?

    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.

    God bless,

  • #2
    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).
    setInterval("myRefresh()", 30000);
    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.


    • #3
      RE: BrainJar, how to call asp from javascript or vice versa

      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.

      and here i have a problem, if i am running the javascript and also the asp together. how do i call one script from another? for instance,

      <script language = javascript>
      setInterval("callASP()", 30000)
      sub callSP()
      ...check if the browser is connected using isConnectedAfter(). else, ...
      end sub

      the example is not working. the above is just a sample, the question is :

      1. how to use javascript and asp together, like "html and asp" or "html and javascript" together?

      2. alternatively, how to call asp function from javascript, or javascript calling asp?

      Please advise, if only i could use them both together. then, it might solve my current problem. thanks

      God bless yah