如何在经典 ASP 中用户注销时禁用浏览器中的后退按钮
每当用户注销或登录 VBScript 时,我需要禁用后退按钮。目前,当用户单击时,它会再次返回到应用程序。我希望用户在单击后退按钮时被定向到登录页面,或者如果我可以禁用后退按钮就可以了。有人可以帮助我吗?
I need to disable the back button whenever the user logsout or gets logged in VBScript. Currently when the user clicks it is going back to application again. I want the user to be directed to login page when he clicks back button or it is fine if I could disable the back button.could anyone help me on this please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法禁用浏览器的后退按钮。这就是网络的运作方式,拥抱它。
也就是说,您可以使页面过期以防止浏览器缓存它们:
查看这篇文章:对“禁用后退按钮”的彻底检查。了解更多信息
You CANNOT disable the back button of the browser. This is the way the web works, embrace it.
That said, you can expire the pages to prevent the browser from caching them:
Check this article: A Thorough Examination of "Disabling the Back Button." for more info
这是一个肮脏的伎俩,但您可以在每个页面的头部包含这个小 javascript:
当然,禁用 javascript 的人将能够很好地使用后退按钮。
我同意 Eduardo 的观点,最好保留后退按钮的功能,如果它不能按预期工作,它会让用户感到沮丧。
最好的解决方案是在每个页面的顶部包含一个内容,检查用户是否登录,如果没有,则重定向到登录页面。
无论如何,您都需要进行检查,因为如果您不对每个页面进行检查,则意味着如果人们知道 URL,则无需登录即可访问该页面。
It's a dirty trick, but you could include this little javascript in the head of every page:
Ofcourse, people that have javascript disabled will be able to use the back button just fine.
I agree with Eduardo, it's better to leave the back button functional, it frustrates users if it doesn't work as expected.
The best solution would be to have an include at the top of every page that checks if a user is logged in and if not, redirect to the login page.
You need to check that anyway, because if you don't check on every page it means that people can go to that page without logging in if they know the URL.
您可以检查每个页面顶部的会话值,如果会话值为空,则重定向到登录页面,因此当用户注销时,它会清除会话值,然后如果有人进入该页面并执行任何操作,它将不允许执行任何操作对该页面进行操作。
you can check session value on top of every page and if session value is blank then redirect to login page, so when user logged out it clear session value then if some one come on that page and do any operation it will not allow to do any operation on that page.