<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>微信退出</title> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> </head> <body> 退出 <script src="scripts/jquery-1.7.1.min.js"></script> <script> $(function(){ pushHistory(); window.addEventListener("popstate", function(e) { // alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能 var i=confirm("你要关闭购物页面?"); if(i){ WeixinJSBridge.call('closeWindow'); }else{ pushHistory(); } }, true); function pushHistory() { var state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); } }); </script> </body> </html>