H5 微信公众号 监听返回事件


/*-----监听返回事件-----*/
function pushHistory(returnUrl,currentUrl,currentTitle) { 
    window.addEventListener("popstate", function(e) { 
        window.location.href=returnUrl;
    }, false); 
    var state = { 
        title: currentTitle, 
        url: currentUrl
    }; 
    window.history.pushState(state, currentTitle, currentUrl); 
} 

具体调用方法:三个参数,

  1.  returnUrl   返回地址

  2.  currentUrl    当前页面地址

  3.  currentTitle   当前页面title

你要返回的地址,

pushHistory("chooseTictik.html","sureOrderTwo.html","确认订单"); 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM