阿富

web前端

导航

【RegExp】IE判断、移动端判断(用正则对navigator.userAgent进行处理)

// 7 || 8 || 9 || 10 || NaN
window.IE = /MSIE/.test(navigator.userAgent) ? parseInt(navigator.userAgent.split(';')[1].replace(/ MSIE /, '')) : NaN;

//true || false
window.IsMobile = /Mobile|iPhone|Android|Windows Phone/.test(navigator.userAgent);

 

posted on 2016-07-14 22:10  阿富  阅读(373)  评论(0)    收藏  举报