BOM (browser object model的缩写,简称浏览器对象模型)
题目:
- 如何识别浏览器的类型
- 分析拆解url各个部分
知识点
- navigator
1
2
3const ua = navigator.userAgent
const isChrome = ua.indexOf('Chrome')
console.log(isChrome) - screen
1
2console.log(screen.width) // 2560
console.log(screen.height) // 1440 - location
1
2
3
4
5
6console.log(location.href); // https://www.baidu.com/?tn=98050039_dg&ch=1#/name/lxl
console.log(location.protocol); // https:
console.log(location.pathname); // /writer
console.log(location.search); // ?tn=98050039_dg&ch=1
console.log(location.hash); // #/name/lxl
console.log(location.host); // "www.baidu.com"