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
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using VBscript or Javascript to check if user closes window or navigates to diff page

    I'm working with asp on my site http://www23.brinkster.com/all4christ and I want to be able to display how many users are browsing the site at anytime.

    I was able to achieve part of this goal using MS Access database..so when someone browses to my site their IP gets recorded and the page displays that their is someone browsing the site....the problem is when the person leaves the site or closes the browser the IP address is not deleted from the table so in essence the page still says the person is still browsing after they've left.

    I have a feeling this could be done using code in a Global.asa file but brinkster.com doesn't allow the Global.asa for free accounts..Is there another way I can get around this like using javascript or vbscipt to check when the user closes the window or navigates to another site so I can delete the IP's

    THanks

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    As far as I know there is no way to use Javascript or anything else to detect when the window closes.

    A lot of systems use the following method:

    1) When someone comes to your site put their details in your database.
    2) On each page they visit check to see if they have already been put in the database (by checking IP or assigned session variable).
    3) If they are already in there then update a column called 'LastAccess' or something similar with the current time.
    4) If they aren't in there, add them.
    5) At the same place that you have this code, delete all records from your database where the 'LastAccess' column has a time that is less than the current time - 5 minutes. This will remove any user that has not accessed a page within the last 5 minutes (or whatever time you choose).
    6) Then you can count the records in the table and display how many people are on your site.

    As far as I know this is a pretty common way of doing it, although I think you are right, you can also do it with the global.asa.

    Hope this gives you some ideas.

  • #3
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks Galdo...this will do. The Global.asa would have worked better but this is still alright. I'll use this...thanks for your help!!


  •  

    Posting Permissions

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