单击“注销”按钮后禁用“浏览器后退”按钮功能 [英] Disable Browser Back Button functionality after click on Logout Button

查看:82
本文介绍了单击“注销”按钮后禁用“浏览器后退”按钮功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中使用了以下代码

I used the below code in master page

<script type="text/javascript">
        function noBack()
         {
             window.history.forward()
         }
        noBack();
        window.onload = noBack;
        window.onpageshow = function(evt) { if (evt.persisted) noBack() }
        window.onunload = function() { void (0) }
    </script>



它对我有用,但我仍然有问题。

因为我在母版页中设置了注销操作,所以浏览器对于与母版页相关联的每个页面都禁用了后退按钮。这是因为,对与主页面关联的每个页面执行代码。

我需要在单击注销时禁用浏览器后退按钮功能。


It is working good for me, but still I have a problem.
As I have set the logout operation in a master page, the browser back button is disabled for every page associated with the master page.It is because,code is executed for every page associated with the master page.
I need to Disable Browser Back Button functionality only when logout is clicked.

推荐答案

您应该检查用户在应用程序页面上的身份验证而不是禁用后退功能

(即检查用户是否已登录)登录页面和用户是否有正确的密钥)如果他没有,他应该被重定向到登录页面。

你可以通过在你的应用程序上应用适当的身份验证来做到这一点。



了解更多信息rmation go here

http://msdn.microsoft。 com / en-us / library / 532aee0e(VS.71).aspx [ ^ ]
Instead of disabling back functionality you should check user's authentication on your application's pages
(i.e check whether the user has logged in from login page and user has proper keys or not) if he doesn't that he should be redirected to the login page.
You could do this by applying proper authentication on your application.

for more information go here
http://msdn.microsoft.com/en-us/library/532aee0e(VS.71).aspx[^]


srikanthvuppula写道:我需要在点击退出时禁用浏览器后退按钮功能。



不,你没有。您需要重新考虑您的应用程序逻辑,以便用户按下后退按钮无关紧要。



您知道在查看时是否有人登录一个页面,所以为什么不简单地显示一条消息你必须登录才能查看此页面,或者显示通用的,非用户特定的信息,或者如果他们在未登录时查看页面,则最强制重定向。 br />


不要试图弄乱浏览器。它或者只是偶尔工作,然后,仅适用于那些启用了javascript的人,并且受制于编写浏览器的人的想法。
srikanthvuppula wrote: I need to Disable Browser Back Button functionality only when logout is clicked.

No you don't. You need to rethink your application logic so that it doesn't matter if the user presses the back button.

You know whether or not a person is logged in when viewing a page, so why not simply display a message "you must be logged in to view this page", or display generic, nonm-user-specific information, or at worst force a redirect if they view a page while not logged in.

Don't try and mess with the browser. It's either going to only work sporadically, and then, only for those with javascript enabled, and is subject to the whims of those who write the browsers.






您的代码并非支持所有浏览器。检查所有浏览器。你必须在你的代码中处理这个问题。所以不要浪费你的时间在浏览器后退按钮。
Hi,

Your code is not all browser supported. Check it for all browser. You have to handle this thing into your code. So don't wast your time in browser back button.


这篇关于单击“注销”按钮后禁用“浏览器后退”按钮功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆