游客
游客
阅读:452 回复:0

手机打开自动跳转到相应页面代码

楼主#
更多 发布于:2016-12-19 16:51

如在商品详情页,扫描后,就自动在手机上显示该商品页,而不是跳转到首页;

代码如下:

<script> 

(function(Switch){
var switch_pc = window.location.hash;
var thisURL = document.location.href.replace(/^http://www.***.com/Home/,"http://www.***.com/mobile");
if(switch_pc != "#pc"){
    if(/iphone|ipod|ipad|ipad|Android|nokia|blackberry|webos|webos|webmate|bada|lg|ucweb|skyfire|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile/i.test(navigator.userAgent.toLowerCase())){
        Switch.location.href = thisURL ;
    }
  }
})(window);

</script>


如果没有隐藏index.php的,要再加上这个才行;


如何隐藏index.php:

http://www.tp-shop.cn/Doc/Index/article/id/250.html



游客

返回顶部