拜请大侠解释一段asp里的script代码

来源:百度知道 编辑:UC知道 时间:2024/06/06 02:17:25
<%
if session("user_name")="" then
response.write "<html><head></head><body><script>top.document.location.href='index.asp';</script></body></html>"
response.end
end if
%>
特别是script标签里的语句是什么意思!
谢谢了!

top.document.location.href='index.asp'

意思是上级窗口转向到index.asp

看这个总体的代码意思是:当用户登录超时或者用户身份不合法时,自动转向到登录的页面。以确保网站信息安全。

如果未登录,整个页面跳转到index.asp页面 ,
没有猜错的话,可能是页面是由frame组成的,所以要加个top

script里的意思是跳转到index.asp,整个过程就是登陆成功跳转到首页。
这个代码太长了点。
<%
if session("user_name")="" then
Response.redirect "index.asp"
end if
%>
用上面的代码就可以完全代替,而且执行更快。