Judge mobile terminal browser version information based on javascript implementation
- 2020-03-30 04:33:13
- OfStack
The explanation is in the comments, so without further ado, I'll just hand you the code
<script type="text/javascript">
/*
* Smartphone browser version information :
*
*/
varbrowser={
versions:function(){
varu = navigator.userAgent, app = navigator.appVersion;
return{//Mobile terminal browser version information
trident: u.indexOf('Trident') > -1,//IE kernel
presto: u.indexOf('Presto') > -1,//The opera kernel
webKit: u.indexOf('AppleWebKit') > -1,//Apple, Google kernel < br / >
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //Firefox kernel
mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/),//Is it a mobile terminal
ios: !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/),//Ios terminal
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //Android terminal or uc browser
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //Is it iPhone or QQHD browser
iPad: u.indexOf('iPad') > -1,//Whether the < br / >
webApp: u.indexOf('Safari') == -1//Whether the web should be program, no header with bottom
};
}(),
language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
document.writeln(" Language version : "+browser.language);
document.writeln(" Is it a mobile terminal : "+browser.versions.mobile);
document.writeln(" ios terminal : "+browser.versions.ios);
document.writeln(" android terminal : "+browser.versions.android);
document.writeln(" Whether it is iPhone: "+browser.versions.iPhone);
document.writeln(" Whether or not iPad: "+browser.versions.iPad);
document.writeln(navigator.userAgent);
</script>
The browser version of the common mobile terminal is basically here, there is a need for friends to refer to it