Function 如何将vbscript复制到函数并在触发body onload时运行它

Function 如何将vbscript复制到函数并在触发body onload时运行它,function,vbscript,onload,onload-event,Function,Vbscript,Onload,Onload Event,我继承了一个主要是vbscript/asp的站点。在DOCTYPE HTML PUBLIC之前有一个页面。。。行并在页面打开之前运行。我需要让它运行,即使用户按下另一个页面上的后退按钮到达那里。大概是把它放在一个onload函数中,对吗 这是一段简短的代码: 不幸的是,您所要求的在VBScript/ASP中是不可能的。VBScript/ASP是一种服务器端编程语言,您试图使用它来诱导客户端行为。如果要执行类似操作,必须使用Javascript或设置“元刷新”值: <% if not

我继承了一个主要是vbscript/asp的站点。在DOCTYPE HTML PUBLIC之前有一个页面。。。行并在页面打开之前运行。我需要让它运行,即使用户按下另一个页面上的后退按钮到达那里。大概是把它放在一个onload函数中,对吗

这是一段简短的代码:



不幸的是,您所要求的在VBScript/ASP中是不可能的。VBScript/ASP是一种服务器端编程语言,您试图使用它来诱导客户端行为。如果要执行类似操作,必须使用Javascript或设置“元刷新”值:


<%
if not (IsEmpty(Session("MM_Username"))) then
    Set checkSet = Server.CreateObject("ADODB.Recordset")
        checkSet.ActiveConnection = MM_CA_STRING
        checkSet.Source = "SELECT * FROM cpgdb.dbo_tbl_printing_tempstore WHERE username = '" & Session("MM_username") & "' AND addedtocart = 'NO'"
        checkSet.Open()

end if
%>
<!DOCTYPE HTML PUBLIC...
...
<body>
<!DOCTYPE HTML PUBLIC...
...
<body onload="runcode()">

Function runcode()
    if not (IsEmpty(Session("MM_Username"))) then
        Set checkSet = Server.CreateObject("ADODB.Recordset")
        checkSet.ActiveConnection = MM_CA_STRING
        checkSet.Source = "SELECT * FROM cpgdb.dbo_tbl_printing_tempstore WHERE username = '" & Session("MM_username") & "' AND addedtocart = 'NO'"
        checkSet.Open()

    end if
End Function
<meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->

<meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->

<meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->