Click here to Skip to main content
14,668,708 members
Rate this:
Please Sign up or sign in to 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 complete code shown in the following

<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";
      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";



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
Updated 14-Jan-19 6:28am
Comments 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..

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try below one :

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

Useful link :[^]
Rate this:
Please Sign up or sign in to vote.

Solution 2

Sory frnds...actually the problem related with alert() function...not related with SetTimeout()..

I replace the alert () with one custom control
Member 9438513 27-Jan-14 6:40am
Please share solution related to alert , i m having same problem..
Rate this:
Please Sign up or sign in to vote.

Solution 3

Google has changed the Content Security Policy which impacts using setTimeout() in some browsers. Please read:
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100