HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 21st, 2004, 01:35 AM
Matt71 Matt71 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 21 Matt71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Javascript Timer

I am thinking of implementing a method of checking if users have just closed a browser window, instead of logging out of the site correctly. My thought was to have a Timer function written in Javascript that would write a time to a database every 5 minutes, then if someone closed the browser and then tried to log in again, if the time period between now and the last time that had been written was greater than 5 I could assume that they had incorrectly logged out.

My question is, as I don't know how to write to a database in Javascript, or even if it's possible, is it possible to include VB Script within a Javascript function? Also as I am not too familiar with Javascript, if anyone has any suggestions on what is written below and how to improve it I'm all ears.

Here is what I would expect the structure to look like:

var gTimer2 = null;
var gTimer2Count = 0;

function Timer2()
{
gTimer2Count++;

<%
strsql = "select * from Register WHERE userid = '" & Useridvariable "';"
sqlRecordset.open strsql, cnDB, 1, 3

sqlRecordset("LatestTime") = now()
sqlRecordset.update

sqlRecordset.close
%>

}
gTimer2 = window.setInterval("Timer2()",300000);


Is this at all possible, or can someone perhaps comment on how it might be achieved. I realise, after looking on the net, and through this forum, that people closing the browser window without logging out is not an easy thing to catch, so just thought that this might work in my case.

Reply With Quote
  #2  
Old May 21st, 2004, 02:20 AM
Yeruhn's Avatar
Yeruhn Yeruhn is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Netherlands
Posts: 428 Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 35 m 27 sec
Reputation Power: 10
You cannot update a server side database with client side code.
Can't you do something with cookies? Set one when they login and remove it when the correctly log out?

Reply With Quote
  #3  
Old May 21st, 2004, 03:58 AM
iht4 iht4 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 83 iht4 User rank is Sergeant (500 - 2000 Reputation Level)iht4 User rank is Sergeant (500 - 2000 Reputation Level)iht4 User rank is Sergeant (500 - 2000 Reputation Level)iht4 User rank is Sergeant (500 - 2000 Reputation Level)iht4 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 20 h 59 m 28 sec
Reputation Power: 12
Question

What about an onclose event which opens a new window, pulls some code from the server which can update your server side database, generates a simple "thanks for using my ace site" message and closes the new window.

might be stopped by pop-up software, but might just be a different direction to view the problem from?

HTH
Iain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Javascript Timer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway