一、JS Web API-BOM
BOM(Browser Object Model)
- 如何识别浏览器的类型
- 分解拆解url各个部分
1. navigator
history
screen
location
navigator
jsconst ua = navigator.userAgent const isChrome = ua.indexOf('Chrome') console.log(isChrome)
screen
jsconsole.log(screen.width) console.log(screen.height)
location
jsconsole.log(location.href) //网址 console.log(location.protocol) //协议 console.log(location.host) //域名 console.log(location.search) //取网址中的参数,一般是?后面的符号
history
jshistory.back() //后退 history.forward() //前进