zoukankan      html  css  js  c++  java
  • 微信浏览器内禁止页面回退返回

    <script type="text/javascript">

        //禁止浏览器回退/返回
        XBack = {};
        (function (XBack) {
            XBack.STATE = 'x - back';
            XBack.element;
            XBack.onPopState = function (event) {
                event.state === XBack.STATE && XBack.fire();
                XBack.record(XBack.STATE); //初始化事件时,push一下
            };
            XBack.record = function (state) {
                history.pushState(state, null, location.href);
            };
            XBack.fire = function () {
                var event = document.createEvent('Events');
                event.initEvent(XBack.STATE, false, false);
                XBack.element.dispatchEvent(event);
            };
            XBack.listen = function (listener) {
                XBack.element.addEventListener(XBack.STATE, listener, false);
            };
            XBack.init = function () {
                XBack.element = document.createElement('span');
                window.addEventListener('popstate', XBack.onPopState);
                XBack.record(XBack.STATE);
            };
        })(XBack); // 引入这段js文件
        XBack.init();
        XBack.listen(function () { });

    </script>

  • 相关阅读:
    vb 退出窗口提示
    游戏开发 简介
    gridview 缓存 优化
    Android中Bitmap和Drawable
    解析网络 xml 流程
    vb 检测是否突然断网
    进度条
    网站广告
    android 五大布局
    VB 读写文件
  • 原文地址:https://www.cnblogs.com/lgq880821/p/10627265.html
Copyright © 2011-2022 走看看