联系官方销售客服
1835022288
028-61286886
pos3开启自动识别移动端,但希望为手机增加手动切换为电脑版,以下代码哪里需要改动?
按照官方手册 https://www.xunruicms.com/v3doc/2463.html
手机模板里加了“电脑版”切换,但由于开启了自动识别移动端,所以又转回了手机版,需求是正常情况下自动识别手机版,但也可以手动切换到pc版,这个怎么解决?
<a href="javascript:dr_goto_pc();">电脑版</a> | <a href="javascript:dr_goto_mobile();">手机版</a> <script type="text/javascript" src="{THEME_PATH}js/jquery.cookie.js"></script> <script type="application/javascript"> var MobileUA = (function() { var ua = navigator.userAgent.toLowerCase(); var mua = { IOS: /ipod|iphone|ipad/.test(ua), //iOS IPHONE: /iphone/.test(ua), //iPhone IPAD: /ipad/.test(ua), //iPad ANDROID: /android/.test(ua), //Android Device WINDOWS: /windows/.test(ua), //Windows Device TOUCH_DEVICE: ('ontouchstart' in window) || /touch/.test(ua), //Touch Device MOBILE: /mobile/.test(ua), //Mobile Device (iPad) ANDROID_TABLET: false, //Android Tablet WINDOWS_TABLET: false, //Windows Tablet TABLET: false, //Tablet (iPad, Android, Windows) SMART_PHONE: false //Smart Phone (iPhone, Android) }; mua.ANDROID_TABLET = mua.ANDROID && !mua.MOBILE; mua.WINDOWS_TABLET = mua.WINDOWS && /tablet/.test(ua); mua.TABLET = mua.IPAD || mua.ANDROID_TABLET || mua.WINDOWS_TABLET; mua.SMART_PHONE = mua.MOBILE && !mua.TABLET; return mua; }()); //SmartPhone if (!MobileUA.SMART_PHONE && !$.cookie('POSCMS_my_test_code')) { // 电脑链接地址 // 跳转首页 //document.location.href = 'http://www.POSCMS.net'; //跳转对应当前页的写法 document.location.href = '{str_replace('m.POSCMS.net', 'www.POSCMS.net', $my_web_url)}'; } }); // 切换手机端 function dr_goto_mobile() { $.cookie('POSCMS_my_test_code', '1', {expires: 7, path: '/', domain: 'POSCMS.net'}); // 跳转首页 //document.location.href = 'http://m.POSCMS.net'; //跳转对应当前页的写法 document.location.href = '{str_replace('www.POSCMS.net', 'm.POSCMS.net', $my_web_url)}'; } // 切换电脑端 function dr_goto_pc() { $.cookie('POSCMS_my_test_code', '1',{expires: 7, path: '/', domain: 'POSCMS.net'}); // 跳转首页 //document.location.href = 'http://www.POSCMS.net'; //跳转对应当前页的写法 document.location.href = '{str_replace('m.POSCMS.net', 'www.POSCMS.net', $my_web_url)}'; } </script>