Link to home
Start Free TrialLog in
Avatar of weeezl
weeezl

asked on

Confirm Countdown

I have a script that is for managing user sessions. Before the user's session ends, a confirm dialouge pops up asking if the user would like to renew their session.

My question is, can I have the actual alert box time out after 60 seconds if no option is selected?
Also, can the confirm box display a countdown or does this have to be done on an HTML page/window?

Here is the code:
<cfif IsDefined("url.sessionwatch")>
<html>
<head><title></title></head>
<body>
<table width="100%"><tr><td align="center"><form>
Session extended.<br>
<input type="submit" onclick="window.close();" value="OK">
</form></td></tr>
</table>
<script>
window.close();
</script>
</body></html>
<cfabort>
</cfif>

<cfparam name="attributes.launchTime" default="20">

<cfoutput>
<cfset thisLaunchTime = (attributes.launchTime * 60 * 1000)>

<script language="Javascript">
     function watchSession() {
          timerID = setTimeout("refreshSession()", #thisLaunchTime#);
     }
     
     function refreshSession() {
          if (confirm("Your session will timeout in 60 seconds. Would you like to extend the session?")) {
               
               
               serverCall = window.open(document.location.href.split("?")[0]+"?sessionwatch=1", "RefreshSession", "width=150, height=50");
               watchSession();
          }
          else window.location="logout.cfm";
     }

     watchSession();
</script>
</cfoutput>
Avatar of webandit
webandit

You definitly have to use a small html window for that.  There is no way to control a dialog box with javascript.  For security reasons, it makes sense, because of all the popup ad idiots out there.  If we were able to control events of a dialog box, we would have less security as a user for the choice.
You will have to mimic the dialog box with a new window.  You could get it really close if you press the print screen button, and slice up the dialog box image.  Could look really fancy.

Sorry

J
*******************************************************
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
*******************************************************
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area:
RECOMMENDATION:

 - [PAQ No Refund]

Please leave any comments here within the next seven days.
*******************************************************
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
*******************************************************

jAy
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpazMODic
SpazMODic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial