1、window.location——获取浏览器地址浏览器
描述:返回结果的数据格式是个对象,还有不少子方法url
经常使用方法:spa
(1)window.location.href ——浏览器地址code
描述:获取到的和window.location内容同样对象
(2)window.location.search ——获取url?后面的内容blog
(3)window.location.hash —— url#后面的内容字符串
2、window.navigator.userAgent —— 获取浏览器信息hash
描述:浏览器不一样结果不一样。包括浏览器内核,当前版本等io
方法:class
(1)判断浏览器是不是IE
if ( window.navigator.userAgent.indexOf('MSIE') != -1 ) { //查找字符串MSIE,若是MSIE存在,就是IE alert('我是ie'); } else { alert('我不是ie'); }