在浏览器中打开页面时,点击手机物理键和浏览器的返回按钮,返回到浏览器的初始化页面,针对这个事情,做了一些处理。

js监听浏览器后退事件

这是自己写的代码,能在微信和浏览器通用,但是UC和夸克浏览器中不太好使

<script>

        var state = {

            title:"手机银行",

            url:'page/index.html'+document.location.hash

        }

        window.history.pushState(state,"手机银行",'page/index.html'+document.location.hash);

        setTimeout(function(){

            window.addEventListener("popstate",function(){

                var state = {

                    title:"手机银行",

                    url:'page/index.html'+document.location.hash

                }

                window.history.pushState(state,"手机银行",'page/index,html'+document.location.hash);

            })

 

        },0);

    </script>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-12-06
  • 2021-10-06
  • 2022-03-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案