Stories

Detail Return Return

js判斷是否手機模式 - Stories Detail

function autoLoad() {
                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"; //uc手機瀏覽器
                var bIsAndroid = sUserAgent.match(/android/i) == "android";
                var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; //windows 移動平台
                var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
                if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
                    window.location.href = 'http://m.abc.com/';     //移動端域名
                }
            }

 

Add a new Comments

Some HTML is okay.