danarashad
Programmer
I have a timer on my page but it doesn't show when someone uses safari, I have posted code. Thanks in advance.
<script language="JavaScript">
<!--
var thisTime = <cfoutput>#userTimeOut#</cfoutput>;
var timerID = null;
var timerRunning = false;
var startDate;
var startSecs;
var SessionKill = thisTime*60;
function startclock()
{
startDate = new Date()
startSecs = (startDate.getHours()*60*60) + (startDate.getMinutes()*60)+ startDate.getSeconds()
showtime()
}
function showtime()
{
// this doesn't work correctly at midnight...
var now = new Date();
var nowSecs = (now.getHours()*60*60) + (now.getMinutes()*60) + now.getSeconds();
var elapsedSecs = SessionKill - (nowSecs - startSecs);
if(elapsedSecs == 299){
alert("Session will time Timed Out in 5 minutes.\n\n Any Data Not Saved will be lost!");
}
if(elapsedSecs < 1){
var path = "<CFOUTPUT>#webpath#/ComCenter/</CFOUTPUT>";
var URL = 'logout.cfm';
var thisTime = 0;
window.location.href = URL;
alert("Session Has Timed Out\n\n Any Data Not Saved will be lost!");
}
else {
var minutes = Math.floor( elapsedSecs / 60 );
elapsedSecs = elapsedSecs - (minutes*60);
var seconds = elapsedSecs;
var timeValue = "";
timeValue += ((minutes < 10) ? "0" : "") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
document.all('timer').value = timeValue;
timerID = setTimeout("showtime()",1000);
}
}
//--></script>
the display is here
<input name="timer" size="4" readonly="true">
<script language="JavaScript">
<!--
var thisTime = <cfoutput>#userTimeOut#</cfoutput>;
var timerID = null;
var timerRunning = false;
var startDate;
var startSecs;
var SessionKill = thisTime*60;
function startclock()
{
startDate = new Date()
startSecs = (startDate.getHours()*60*60) + (startDate.getMinutes()*60)+ startDate.getSeconds()
showtime()
}
function showtime()
{
// this doesn't work correctly at midnight...
var now = new Date();
var nowSecs = (now.getHours()*60*60) + (now.getMinutes()*60) + now.getSeconds();
var elapsedSecs = SessionKill - (nowSecs - startSecs);
if(elapsedSecs == 299){
alert("Session will time Timed Out in 5 minutes.\n\n Any Data Not Saved will be lost!");
}
if(elapsedSecs < 1){
var path = "<CFOUTPUT>#webpath#/ComCenter/</CFOUTPUT>";
var URL = 'logout.cfm';
var thisTime = 0;
window.location.href = URL;
alert("Session Has Timed Out\n\n Any Data Not Saved will be lost!");
}
else {
var minutes = Math.floor( elapsedSecs / 60 );
elapsedSecs = elapsedSecs - (minutes*60);
var seconds = elapsedSecs;
var timeValue = "";
timeValue += ((minutes < 10) ? "0" : "") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
document.all('timer').value = timeValue;
timerID = setTimeout("showtime()",1000);
}
}
//--></script>
the display is here
<input name="timer" size="4" readonly="true">