使用经典asp在javascript中获取服务器时间
这一次我把头发拔了出来。我将下面的经典ASP代码放在我的文档头中,以获得在javascript中使用的服务器时间。。。这是第一次成功。稍后,当javascript调用javascript中的相同函数时,我只需要2分钟的时间 第一次在头部周围(OK)使用经典asp在javascript中获取服务器时间,javascript,asp-classic,Javascript,Asp Classic,这一次我把头发拔了出来。我将下面的经典ASP代码放在我的文档头中,以获得在javascript中使用的服务器时间。。。这是第一次成功。稍后,当javascript调用javascript中的相同函数时,我只需要2分钟的时间 第一次在头部周围(OK) window.servertime='';//再次获取服务器! 每次第二个函数运行2分钟 servertime变量是在最初呈现页面时计算的,只有在再次调用页面时才会更新 这意味着,如果要使用当前服务器时间,可以执行以下几项操作: 当页面加载时,抓
window.servertime='';//再次获取服务器!
每次第二个函数运行2分钟 servertime变量是在最初呈现页面时计算的,只有在再次调用页面时才会更新 这意味着,如果要使用当前服务器时间,可以执行以下几项操作:
希望这会有帮助。我不知道你需要时间做什么。。。当用户会话即将到期时,我用它在asp页面中提前2分钟发出警告
<%
advanceWarning = 2
jsTimeout = (session.timeout - advanceWarning) * 60000
%>
<script>window.setTimeout("alert('Security Message at <%=time%> (EST): You have been idle for too long on the website. For your security, your session will expire in 2 minutes and you will be automatically logged out if you continue to remain idle!');",<%=jsTimeout%>);</script>
window.setTimeout(“警报((EST时的安全消息):您在网站上空闲的时间太长了。为了您的安全,您的会话将在2分钟后过期,如果您继续空闲,您将自动注销!”;“,);
asp经典?!2013年?!我想你的时间确实有问题……我仍然会说英语,而且有点老:)@hillcreative你意识到ASP的东西是在服务器上解决的,一旦它进入浏览器,那些ASP表达式早就不存在了,对吗?迈克,谢谢你的建议,但那段代码与我想做的相去甚远。关于如何改进代码有什么建议吗?
<%
d = Now
servertime = Cstr(Right("00" & Hour(d), 2) & ":" & Right("00" & Minute(d), 2) & ":" & Right("00" & Second(d), 2)) 'parse out hh:mm:ss
%>
window.servertime = '<%=servertime%>'; // get the server time again!
<%
advanceWarning = 2
jsTimeout = (session.timeout - advanceWarning) * 60000
%>
<script>window.setTimeout("alert('Security Message at <%=time%> (EST): You have been idle for too long on the website. For your security, your session will expire in 2 minutes and you will be automatically logged out if you continue to remain idle!');",<%=jsTimeout%>);</script>