Navigator 对象包含有关浏览器的信息。很多时候我们需要在判断网页所处的浏览器和平台,Navigator为我们提供了便利
1.掌握Navigator对象的userAgent属性2.掌握如何判断浏览器的类型3.掌握如何判断设备的终端是移动还是PCUserAgent:用来识别浏览器名称,版本,引擎以及操作系统等信息的内容。//检测浏览器类型if(/Android|iphone|webOS/i.test(navigator.userAgent)){location.href="mobile.html"}else if(/ipad/i.test(navigator.userAgent)){location.href="pad.html"}
<script>console.log(navigator.userAgent)</script>
