如何实现PC端地址向移动端地址的自动适配?
- 内容介绍
- 文章标签
- 相关推荐
本文共计485个文字,预计阅读时间需要2分钟。
在手机端访问PC端URL地址,自动跳转到对应的m端地址。判断当前设备类型,如果是移动设备且在移动设备上访问PC论坛,自动跳转到M端论坛。
javascriptfunction mobile_device_detect(url) { var thisOS=navigator.platform; if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(thisOS)) { if (url.indexOf(pc) > -1) { var mUrl=url.replace(pc, m); window.location.href=mUrl; } }}
在手机端访问pc端的url地址,自动转跳到对应的m端地址//判断当前设备类型,如果是在移动设备上面进入pc论坛,自动跳转到M端论坛
function mobile_device_detect(url){
var thisOS=navigator.platform;
var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
for(var i=0;i
本文共计485个文字,预计阅读时间需要2分钟。
在手机端访问PC端URL地址,自动跳转到对应的m端地址。判断当前设备类型,如果是移动设备且在移动设备上访问PC论坛,自动跳转到M端论坛。
javascriptfunction mobile_device_detect(url) { var thisOS=navigator.platform; if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(thisOS)) { if (url.indexOf(pc) > -1) { var mUrl=url.replace(pc, m); window.location.href=mUrl; } }}
在手机端访问pc端的url地址,自动转跳到对应的m端地址//判断当前设备类型,如果是在移动设备上面进入pc论坛,自动跳转到M端论坛
function mobile_device_detect(url){
var thisOS=navigator.platform;
var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
for(var i=0;i

