Link to home
Start Free TrialLog in
Avatar of sporenza
sporenza

asked on

Session Timeout

All,

I have a question:

I have this page to handel timeouts:


<SCRIPT LANGUAGE="VBScript">
<!--
     Dim intTimerID
     min=30          'change minutes
     sec=0          'change seconds
     
     Sub HandleTime
     if min=0 and sec=0 then
          endtime
     elseif min=28 and sec>0 then
          sec=sec-1
          min=min-1
          sec=59
          status=hr & ":" & min & ":" & sec
          intTimerID=setTimeOut("HandleTime",950, "VBScript")
        SessionAlert
     elseif min>=0 and sec>0 then
          sec=sec-1
          status=hr & ":" & min & ":" & sec
          intTimerID=setTimeOut("HandleTime",950, "VBScript")
     elseif min>0 and sec=0  then
          min=min-1
          sec=59
          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")
               
-->
</SCRIPT>


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!

Thanks,
Sporenza

ASKER CERTIFIED SOLUTION
Avatar of anthonywjones66
anthonywjones66

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can alway use single quotes

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

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