控制获取监听安卓手机物理返回键的事件

<script> // 控制手机物理键--返回window.onload = function(){  if(window.history && window.history.pushState) {        $(window).on('popstate', function() {           ...
<script> 
// 控制手机物理键--返回
window.onload = function(){
  if(window.history && window.history.pushState) {  
      $(window).on('popstate', function() {  
          var hashLocation = location.hash;  
          var hashSplit = hashLocation.split("#!/");  
          var hashName = hashSplit[1];  
          if(hashName !== '') {  
              var hash = window.location.hash;  
              if(hash === '') {  
                  alert("你点击了返回键");  
                  //location.href ='/xcview/html/apprentice/inherited_introduction.html'  /*跳转链接*/
              }  
          }  
      });  
      window.history.pushState('forward', null, './#forward');    //引号里写当前页面地址,刷新当前页'./inherited_introduction.html'
  }
};
</script> 

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章