Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2008, 09:17 AM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to set the maximum minutes in setTimeout() or

Hi Friends,

I have to call the function automatically, after 55th minute. So I'm planning to use setTimeout function in javascript. But it's correctly working for only below 15 minutes. If I give more than 15 it's not working. can you please tell me how to set 55 minutes. I'm using the following code.

function SetTimer(){
var dblMinutes = 55*60000;
timerObj = setTimeout("ConfirmUpdate()",timeoutMinutes);
}
setTimert();

My requirement is 5 minutes before session out, I have to show the messgae "your session is going to expire. Press ok to renew the session".So only I'm trying the above the option. Is there any other way to show this message?please help me. session out is 60 mins.
regards
Kasi
__________________
Regards
Kasi
 
Old February 18th, 2008, 10:36 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Kasi!!
in your code where you have defined
timeoutMinutes ??
and where is setTimert() ?? its setTimer() ,function case sensistive ??

well alway try to put exact code this will help other to find out the solution.
following is the solution
<script>



  var sessionTimeOutInMin=60; //In minute session time out
  var sessionTimeOutInSec=sessionTimeOutInMin*60;

            function setTimer() {

            var MinsLeft=(sessionTimeOutInSec-(sessionTimeOutInSec % 60))/60;
            var SecsLeft=sessionTimeOutInSec % 60;


            sessionTimeOutInSec=sessionTimeOutInSec-1;



            if (MinsLeft==5 & SecsLeft==0)
            {
            alert('5 Mints left')
            }

            if (MinsLeft==0 & SecsLeft==0) {
            alert('Finally TimeOut')
            }

        }


        window.setInterval("setTimer()",1000);
        setTimer();

</script>

Cheers :)

vinod
 
Old February 18th, 2008, 12:37 PM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your quick response.
Sincere apologies, I copied the code, wrongly.
Here is the right code
function setTimer(){
var timeoutMinutes= 55*60*1000;//Timoutperiod, Minutes,Milli seconds
timerObj = setTimeout("ConfirmUpdate()",timeoutMinutes);
}
setTimer();
ConfirmUpdate() method has the session checking code. And I'm clearing the timer whenever the page is getting reloaded function clearTimerFn(){
clearTimeout(timerObj);
}
can you please tell me, what is wrong in it? which one should I use? setTimeout or setInterval?plz let me know if you need more input from my code.

Regards
Kasi





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert time to minutes stolte XSLT 3 November 21st, 2008 04:12 AM
Calculate time (minutes) between two times rtr1900 Classic ASP Basics 18 January 2nd, 2008 03:06 PM
Remoting timing out after 2 minutes BrainWave ASP.NET 2.0 Professional 0 August 13th, 2007 06:54 AM
Calculating hours and minutes between to dates timmaher Access VBA 4 May 10th, 2005 07:36 AM
set maximum session time through program vinodkalpaka Beginning PHP 1 December 17th, 2004 10:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.