Session Timeout

Posted on 2005-04-10
Last Modified: 2008-01-09

I have a question:

I have this page to handel timeouts:

     Dim intTimerID
     min=30          'change minutes
     sec=0          'change seconds
     Sub HandleTime
     if min=0 and sec=0 then
     elseif min=28 and sec>0 then
          status=hr & ":" & min & ":" & sec
          intTimerID=setTimeOut("HandleTime",950, "VBScript")
     elseif min>=0 and sec>0 then
          status=hr & ":" & min & ":" & sec
          intTimerID=setTimeOut("HandleTime",950, "VBScript")
     elseif min>0 and sec=0  then
          status=hr & ":" & min & ":" & sec
          intTimerID=setTimeOut("HandleTime",950, "VBScript")
     End Sub
     Sub endtime
          cleartimeout intTimerID
             status = "Your Time Ended"      
          msgbox "Time Up"    
     end sub

      Sub SessionAlert(popmessage, poptime)
         '-- popmessage is the message that will be displayed to the user when the timer expires.
         '-- it should be properly escaped for display in javascript
         '-- poptime is the amount of time (in minutes) that you want the message to be displayed prior to session timeout
         Response.Write "<script language=""JavaScript"" type=""text/javascript"">" & vbCrLf
         Response.Write "setTimeout('alert(\'" & popmessage & "\');'," & (Session.Timeout-poptime) * 60 * 1000 & ");" & vbCrLf
         Response.Write "</script>" & vbCrLf
      End Sub

     status=min & ":" & sec
     intTimerID=setTimeOut("HandleTime",950, "VBScript")

My problem is on the line:         Response.Write "<script language=""JavaScript"" type=""text/javascript"">" & vbCrLf
I get this error: A script block cannot be placed inside another script block.

Please help.  I am trying to give a timeout but give the user a warning that they are about to be signed off!


Question by:sporenza
    LVL 8

    Accepted Solution

          Response.Write "<scr" + "ipt language=""JavaScript"" type=""text/javascript"">" & vbCrLf


           Response.Write "</scr" + "ipt>" & vbCrLf

    LVL 13

    Expert Comment

    you can alway use single quotes

    Response.Write("<script language='JavaScript' type='text/javascript'>" & vbCrLf)

    Response.Write("</script>" & vbCrLf)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now