Click here to Skip to main content
15,885,920 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hai Friends,

i called one javascript inbuilt function setTimeout('SessionWarning()', 2000).This function singout ma application after 2000 milleseconds.This function working fine in Firefox but not good in Chrome..my complete code shown in the following

XML
<script language="javascript" type="text/javascript" charset="utf-8">


      var authorized = "<%= HttpContext.Current.User.Identity.IsAuthenticated.ToString().ToLower() %>";
      if (getAbsolutePath().toLowerCase() == 'sessionexpired.aspx') {
          authorized = "false";
          //alert(authorized);
      }
      if (authorized == "true") {
          var sessionTimeoutWarning = "<%= Session.Timeout %>";
          sessionTimeoutWarning = sessionTimeoutWarning - 1;
          var sessionTimeout = "<%= Session.Timeout %>";
          var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000;
          setTimeout('SessionWarning()', sTimeout);


          function SessionWarning() {
              var message = "Your session will expire in another " + (parseInt(sessionTimeout) - parseInt(sessionTimeoutWarning)) + " minute(s)! Please respond before the session expires";
              alert(message);

          }
      }
  </script

>

This function automatically goes to sessionexpired page after specified time in firefox..but in chrome the alert will stay indefintly.if u check alert then it will automatically timeout..

please Help me
Thanks advnc
Aatif-Bangalore
Posted
Updated 14-Jan-19 6:28am
v2
Comments
Samresh.ss 9-Jul-13 5:28am    
setTimeout works in my version of chrome. Must be some other issue. Press ctrl+shift+J and see if you see some error in console.
Aatif Ali from Bangalore 9-Jul-13 5:35am    
Its working partially...In firefox the alert will automatically closed and page redirect to ma specified url..but in chrome the alert will showing indefinitly..It will close whenvr clicking on alert box.and control redirect to specified url at the clicking time.
Member 9438513 27-Jan-14 6:40am    
I am having same problem, can any one please post solution, if this problem related to alert how it is resolved , put solution plz..

Try below one :

setTimeout(function () {SessionWarning();}, sTimeout);


Useful link : http://www.jquery4u.com/jquery-functions/settimeout-example/[^]
 
Share this answer
 
Sory frnds...actually the problem related with alert() function...not related with SetTimeout()..

I replace the alert () with one custom control
 
Share this answer
 
Comments
Member 9438513 27-Jan-14 6:40am    
Please share solution related to alert , i m having same problem..
Google has changed the Content Security Policy which impacts using setTimeout() in some browsers. Please read: https://developer.chrome.com/extensions/contentSecurityPolicy
 
Share this answer
 
Comments
Richard Deeming 18-Jan-19 12:14pm    
IF you apply a CSP, and IF that CSP doesn't specify unsafe-eval as a valid script source, then setTimeout('some-string', ms); won't work.

That's not a change made by Google; that's just how a CSP works.

And it's not relevant to the OP's question, which has already been solved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900