直接看代码吧
// 判断是移动端开始PC端
var device = navigator.userAgent.toLowerCase();
if (/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(device)) {
//移动端
} else {
//pc端
}
PC端跳转移动端
var device = navigator.userAgent.toLowerCase();
if (/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(device)) {
window.location = window.location.href.replace('PC端域名', '移动端域名');
}
移动端跳转PC端
var device = navigator.userAgent.toLowerCase();
if (!(/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(device))) {
window.location = window.location.href.replace('移动端域名', 'PC端域名');
}