美文网首页
前端常用获取版本号,微信,手机等方法

前端常用获取版本号,微信,手机等方法

作者: AlisaMfz | 来源:发表于2017-04-10 14:09 被阅读227次

//获取ios浏览器主版本号

getIosVersion:function() {

var ver =this.navigator.userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/);

if(ver && ver.length>1){

return parseInt(ver[1],10);

}else{

return-1;

}

}

//安卓

android:function() {

return this.navigator.userAgent.indexOf('Android') > -1||this.ua.indexOf('Linux') > -1;

},

//苹果

iPhone:function() {

return this.navigator.userAgent.indexOf('iPhone') > -1;

},

//iPad

iPad:function() {

return this.navigator.userAgent.indexOf('iPad') > -1;

},

//qq浏览器

qq:function() {

return this.navigator.userAgent.indexOf('QQBrowser') > -1;

},

//微信浏览器

weixin:function() {

return this.navigator.userAgent.indexOf('MicroMessenger') > -1;

},

相关文章

网友评论

      本文标题:前端常用获取版本号,微信,手机等方法

      本文链接:https://www.haomeiwen.com/subject/jppsattx.html