1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <script type="text/javascript" src="http://m.people120.org/mobile/js/jquery-1.7.2.min.js"></script> <script> var isWap = navigator.userAgent.match(/iPad|iPhone|iPod|Android/i) != null; if(isWap){ history.pushState(null, null, location.href); document.writeln("<style>"); document.writeln("#htlj_zz{background-color:rgba(0,0,0,0.5);position: absolute;z-index:111;height:100%}"); document.writeln("#htlj{width: 90%;background-color: #ffffff;border-radius: 15px;margin: 30% auto 0;text-align: center;padding: 5% 0;}"); document.writeln("#htlj img{width: 30%;}"); document.writeln("#htlj h3{font-weight: bold;font-size: 2rem;margin: 3% 0}"); document.writeln("#htlj p{font-size: 1.5rem;margin: 3% 0}"); document.writeln("#htlj h2{font-weight: bold;font-size: 1.5rem;color: #fe232a}"); document.writeln("#htlj a{color: white;width: 40%;display: block;margin: 3% auto;padding: 2% 0;font-size: 1.5rem;text-decoration: none;}"); document.writeln("#htlj a:nth-of-type(1){background-color: #0000ff}"); document.writeln("#htlj a:nth-of-type(2){background-color: #b5bbc3}"); document.writeln("</style>"); document.writeln("<div id='htlj_zz'>"); document.writeln("<div id='htlj'>"); document.writeln("<img src='https://xiaohuihui.net.cn/wp-content/uploads/2018/10/smile.png' alt=''>"); document.writeln("<h3>觉得打字太麻烦?</h3>"); document.writeln("<p>马上电话咨询</p>"); document.writeln("<h2>0371-55021062</h2>"); document.writeln("<a href='tel:037155021062'>拨打电话</a>"); document.writeln("<a href='javascript:void(0);' id='rehide'>返回咨询</a>"); document.writeln("</div>"); document.writeln("</div>"); $('#rehide').on('click',function(){ $('#htlj').css('display','none'); }); window.addEventListener('popstate', function(event) { //history.pushState(null, null, location.href ); //此处加入回退时你要执行的代码 $('#htlj_zz').parent().css('display','block'); }); } </script> |
备注:
以上方法可能对应iso(苹果手机)的微信访问的话回退无效,可以使用以下代码解决:
1 2 3 4 5 6 7 8 | history.pushState(null, null, document.URL); window.onhashchange = function () { window.location.href = mycars[selectFrom(0,mycars.length-1)]; }; function hh() { history.pushState(history.length + 1, null, "#" + new Date().getTime()); } setTimeout('hh();', 100); |