Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry 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,
    Gary

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use setInterval() to execute a piece of script code on the browser repeatedly at some time interval:

    Code:
    //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
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool 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
    %>
    </script>

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •