首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    H5 开发中常见的小问题

    1.解决 浏览器 返回按钮不刷新的问题   window.onpageshow = function(event) {     if (event.persisted) {       window.location.reload()   }}; 2.H5 中 JS 禁用安卓手机物理返回键   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() {});

    01
    领券