使用移动应用程序运行应用程序时如何在浏览器中禁用“后退按钮" [英] how to disable Back-Button in Browser while running applications using mobile application

查看:72
本文介绍了使用移动应用程序运行应用程序时如何在浏览器中禁用“后退按钮"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,


我对美国有疑问.

如何在使用移动应用程序运行应用程序时禁用浏览器中的后退按钮".并且不会刷新或重新加载页面.
按下返回按钮时.
????

dear friends,


I have Question For U..

how to disable Back-Button in Browser while running applications using mobile application . and Does Not Page Refreshing or Reload.
While pressing Back Button.
????

推荐答案

您实际上不能禁用浏览器的后退按钮,因为浏览器窗口中正在运行的任何内容都无法访问浏览器菜单项.

但是,可以使用一些JavaScript hack来创建相同的效果.这是对我有用的技巧之一.

You cannot actually DISABLE the back button of the browser because whatever content is running inside the browser window has no access to browser menu items.

However, the same effect can be created using some javascript hacks. Here is one of the trick that worked for me..

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<title>Untitled Page</title> 
<script type = "text/javascript" > 
function changeHashOnLoad() { 
     window.location.href += "#"; 
     setTimeout("changeHashAgain()", "50");  
} 
 
function changeHashAgain() { 
  window.location.href += "1"; 
} 
 
var storedHash = window.location.hash; 
window.setInterval(function () { 
    if (window.location.hash != storedHash) { 
         window.location.hash = storedHash; 
    } 
}, 50); 
 
 
</script> 
</head> 
<body onload="changeHashOnLoad(); "> 
Try to hit the back button! 
</body> 
</html> 


这篇关于使用移动应用程序运行应用程序时如何在浏览器中禁用“后退按钮"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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