本文介绍了如何在ASP.NET C#中使用jquery禁用前进按钮(后退)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个工作正常但在重定向到Page2.htm后尝试按住退格键几秒钟,它会回到page1.htm



这是您在下面看到的代码



This thing works fine but after redirecting to "Page2.htm" try pressing and holding backspace for few seconds, it goes back to "page1.htm"

This is code you saw below

<script>
      $(document).ready(function(){
          function disableBack() {window.history.forward()}
          window.onload = disableBack();
  	  window.onpageshow = function(evt) {if(evt.persisted) disableBack()}
      });
</script>





我尝试过:



我有更多尝试这个主题,但没有正确的答案



What I have tried:

I had more try for this topic but no correct getting answer

推荐答案





我尝试过:



我有更多尝试这个主题,但没有正确的答案



What I have tried:

I had more try for this topic but no correct getting answer


Use of this code : 

// for script code:
<script type="text/javascript" language="javascript">
window.history.forward(1);
document.attachEvent("onkeydown", functionName);
function functionName()
{
switch (event.keyCode)
{
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>
protected void Page_Load(object sender, EventArgs e)
   {
     HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
     HttpContext.Current.Response.Cache.SetNoServerCaching();
     HttpContext.Current.Response.Cache.SetNoStore();
   }


这篇关于如何在ASP.NET C#中使用jquery禁用前进按钮(后退)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 04:39