使用js生成转到登录页面
在网站开发中,我们经常有这样的场景出现:
情景1:对未登录的用户或没有权限的用户,当其想访问某个受限网页时,系统要能够自动转到登录页面.
情景2:对于用Session保存用户状态的情况还有这样一种需求,当用户的Session已超时时,用户再想执行操作时,也要将其转到登录页面.
1. window.location.replace(window.location.href)
2.<head>
<title>登录</title>
</head>
<script type="text/javascript">
if (top.location != self.location) {top.location=self.location;}
</script>
<body></body>
情景1:对未登录的用户或没有权限的用户,当其想访问某个受限网页时,系统要能够自动转到登录页面.
情景2:对于用Session保存用户状态的情况还有这样一种需求,当用户的Session已超时时,用户再想执行操作时,也要将其转到登录页面.
1. window.location.replace(window.location.href)
2.<head>
<title>登录</title>
</head>
<script type="text/javascript">
if (top.location != self.location) {top.location=self.location;}
</script>
<body></body>