leohxj
2/27/2014 - 1:43 AM

user agency detect

user agency detect

(function() {
    var ua = window.navigator.userAgent.toLowerCase();
    window.platform = {
        isiPad: ua.match(/ipad/i) !== null,
        isiPhone: ua.match(/iphone/i) !== null,
        isAndroid: ua.match(/android/i) !== null,
        isBustedAndroid: ua.match(/android 2\.[12]/) !== null,
        isIE: window.navigator.appName.indexOf("Microsoft") !== -1 || ua.match(/rv:11.0/) !== null,
        isIE8: ua.match(/msie 8/) !== null,
        isIE9: ua.match(/msie 9/) !== null,
        isChrome: ua.match(/chrome/gi) !== null,
        isFirefox: ua.match(/firefox/gi) !== null,
        isWebkit: ua.match(/webkit/gi) !== null,
        isGecko: ua.match(/gecko/gi) !== null,
        isOpera: ua.match(/opera/gi) !== null,
        isMac: ua.match('mac') !== null,
        hasTouch: ('ontouchstart' in window),
        supportsSvg: !! document.createElementNS && !! document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect
    };
    platform.isMobile = ua.match(/android|webos|iphone|ipod|blackberry|iemobile/i) !== null && ua.match(/mobile/i) !== null;
    platform.isTablet = platform.isiPad || (ua.match(/android|webos/i) !== null && ua.match(/mobile/i) === null);
    platform.isDesktop = !(platform.isMobile || platform.isTablet);
})();