Analyzing the browser and the mobile terminal or pc

 

/**
 * Determine the browser pc and mobile sides, and jump to a different page
 */
function browserRedirect() {
    var sUserAgent = navigator.userAgent.toLowerCase();
    var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    var bIsAndroid = sUserAgent.match(/android/i) == "android";
    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
     Var bIsWM sUserAgent.match = (/ Windows Mobile / I) == "Windows Mobile" ;
     IF (bIsIpad bIsMidp || || || bIsIphoneOs bIsUc7 || bIsUc bIsCE || || || bIsAndroid bIsWM) {
         // device a mobile terminal 
        the console.log ( 'mobile terminal' );
        
    } else {
        console.log('PC')
    }
}

 

Guess you like

Origin www.cnblogs.com/duanzhenzhen/p/11881280.html