且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用ASP.NET中的浏览器后退按钮

更新时间:2023-10-07 20:47:46

试试这个:



< script type =   text / javascript> 
window history .forward();
function noBack(){ window history 跨度>的.forward(); }
< / script>

< body onload = noBack();>
onpageshow = if(event.persisted)noBack(); onunload = > < / 正文 >


您好,



您需要强制缓存过期才能生效。

将以下代码放在页面代码后面。

 Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)



但是这是一个不好的做法......


通过这种方式强制缓存过期..

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)



另见..

http://lennilobel.wordpress.com/2009 / 07/26 / the-evil-back-button-in-your-asp-net-applications / [ ^ ]

http://www.c-sharpcorner.com/Blogs/763/ [ ^ ]

http://forums.asp.net/t/1135418.aspx/1 [ ^ ]

http://***.com/questions/961188/disable-browsers-back-button [ ^ ]


Disable Browser Back Button and Forword button in ASP.NET

Try this:

<script type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }
</script>

<body  onload="noBack();">
    onpageshow="if (event.persisted) noBack();" onunload=""></body>


Hello,

You need to force the cache to expire for this to work.
Place the following code on your page code behind.
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)


But this is a bad practice ...


Force the cache to expire by this way..
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)


Also see..
http://lennilobel.wordpress.com/2009/07/26/defeat-the-evil-back-button-in-your-asp-net-applications/[^]
http://www.c-sharpcorner.com/Blogs/763/[^]
http://forums.asp.net/t/1135418.aspx/1[^]
http://***.com/questions/961188/disable-browsers-back-button[^]