最新最全的js判断移动设备及操作系统
var navigator = window.navigator, userAgent = navigator.userAgent, android = userAgent.match(/(Android)[\s\/]+([\d\.]+)/), ios = userAgent.match(/(iPad|iPhone|iPod)\s+OS\s([\d_\.]+)/), wp = userAgent.match(/(Windows\s+Phone)\s([\d\.]+)/), isWebkit = /WebKit\/[\d.]+/i.test(userAgent), isSafari = ios ? (navigator.standalone ? isWebkit : (/Safari/i.test(userAgent) && !/CriOS/i.test(userAgent) && !/MQQBrowser/i.test(userAgent))) : false, os = {}; if (android) { os.android = true; os.version = android[2]; } if (ios) { os.ios = true; os.version = ios[2].replace(/_/g, '.'); os.ios7 = /^7/.test(os.version); if (ios[1] === 'iPad') { os.ipad = true; } else if (ios[1] === 'iPhone') { os.iphone = true; os.iphone5 = window.screen.height == 568; } else if (ios[1] === 'iPod') { os.ipod = true; } } if (wp) { os.wp = true; os.version = wp[2]; os.wp8 = /^8/.test(os.version); }