题目
- 如何识别浏览器的类型
- 分析拆解url各个部分
知识点
- navigator
- screen
- location
- history
navigator和screen
//navigator
const ua = navigator.userAgent
const isChrome = ua.indexOf('Chrome')
console.info(isChrome)
//screen
console.info(screen.width)
console.info(screen.height)
location和history
//location
console.info(location.href)
console.info(location.protocol) //'http:' 'https:'
console.info(location.pathname) //'/learn/199'
console.info(location.search)
console.info(location.hash) //
//history
history.back()
history.forward()