如在商品详情页,扫描后,就自动在手机上显示该商品页,而不是跳转到首页;
代码如下:
<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