url smart matching mobile terminal pc terminal

  
  var OnePage = true ; //Used to determine the information of the homepage login in staticHtml.js
var _mobileUrl = "http://192.168.0.5/h" ; //Mobile phone users jump when they are hungry when they visit the website via mobile phones
checkMobileDevice (); //Call monitoring code
function isMobileDevice() {
return (navigator.userAgent. match( /Android/ i) || navigator.userAgent. indexOf( 'iPhone') > - 1
    || navigator.userAgent. indexOf(
'iPod') > - 1 || navigator.userAgent. indexOf( 'iPad') > - 1);
}

function isFromWap() {
return (location.href. indexOf( "from=wap") > - 1);
}

function checkMobileDevice() {
var mobileDevice = isMobileDevice(); //检查是否是手持设备过来的
if (mobileDevice) {
var formWap = isFromWap();
//  if(fromWap!="fromWap"){//检查是否是手机端发送的要登入pc网址
if ( !formWap) {
location.href = _mobileUrl;
return false;
}
}
}

Guess you like

Origin blog.csdn.net/qinyikl/article/details/80136936