zoukankan      html  css  js  c++  java
  • 点击手机自带返回键,指定返回的内容//阻止安卓自带后退//禁止浏览器后退

    
    
    //禁止浏览器后退
    window.history.forward(1);
    
    
    
        第一种
    pushHistory(); function pushHistory() {
    var state = { title: "title", url: "__MODULE__/Index/index" }; window.history.pushState(state, "title", "__MODULE__/Index/index"); } window.addEventListener("popstate", function(e) { $('.order').show(); $('.mask222').hide(); $("#vehicle_Select_List").css('display', 'none'); }, false);
    第二种 
    pushHistory(); window.addEventListener(
    "popstate", function(e) { $('.order2').show(); $("#userSelectMap").animate({ left:"100%", },100); $("#nearDiv").animate({ left:"100%", },100); // $("#userSelectMap").hide(); // return false; // $(window).unbind('scroll'); window.location.href="indexNext.html" }, false); function pushHistory() { var state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); } document.addEventListener("WeixinJSBridgeReady",function(){ WeixinJSBridge.call("showToolbar")});

    // 防止页面后退//阻止安卓机后退
    // 页面载入时使用pushState插入一条历史记录
    history.pushState(null, null, '#' );
    console.log('刷新');
    window.addEventListener('popstate', function(event) {
    console.log('回退');
    // 点击回退时再向历史记录插入一条,以便阻止下一次点击回退
    history.pushState(null, null, '#' );
    });

  • 相关阅读:
    js数字格式化(加千分位逗号)
    [css]解决iframe在ios设备上无法滚动
    判断当前是否在微信浏览器环境
    TortoiseGit 提交代码每次需要输入用户名和密码?
    如何编写jQuery插件
    函数作用域
    HTTP动词
    如何减少全局变量污染?
    mysql表大字段最大长度限制设置
    update left join 多表关联更新
  • 原文地址:https://www.cnblogs.com/yongwang/p/6824582.html
Copyright © 2011-2022 走看看