navigator对象包含有关浏览器的信息,通常用于检测浏览器和操作系统版本
navigator的对象属性包括:
appCodeName:浏览器代码名的字符串表示;
appName:返回浏览器的名称;
appVersion:返回浏览器的操作系统平台;
platform:返回运行浏览器的操作系统平台
uerAgent:返回由客户机发送服务器上午user-agent头部值(就是包括浏览器版本信息等的字符串)
一、我们可以通过MicroMessenger关键字来判读是否是微信
Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12A365 MicroMessenger/5.4.1 NetType/WIFI
js事例

二、判断移动端设备类型

三、使用userAgent判断使用的是什么浏览器

判断是不是特定类型的浏览器,比如新浪weibo客户端内置浏览器,qq客户端内置浏览器,微信内置浏览器

微信版本号判断

四、判断当前网络时断开状态还是连接状态
(function(){
// console.log('已经执行!');
if(!navigator.onLine) {
//alert('请检查网络是否连接!');
var URLerr = document.getElementsByTagName("body")[0];
URLerr.innerHTML = "网络已断开连接";
document.getElementsByTagName("body")[0].style.textAlign="center";
return false;
}
}())
大家如果有更好的请留言,多多学习!