说说对BOM的理解及常见操作
# 是什么
BOM: 浏览器对象模型 browser object model, 是浏览器窗口交互对象
整个浏览器
# 操作
- window
- location
- navigator
- history
- screen
# window
全局对象
- window.open()
- window.close()
# location
获取浏览器地址栏信息
- location.reload()
| 属性名 | 例子 | 说明 |
|---|---|---|
| hash | "#contents" | utl中#后面的字符,没有则返回空串 |
| host | www.wrox.com:80 | 服务器名称和端口号 |
| hostname | www.wrox.com | 域名,不带端口号 |
| href | http://www.wrox.com:80/WileyCDA/?q=javascript#contents | 完整url |
| pathname | "/WileyCDA/" | 服务器下面的文件路径 |
| port | 80 | url的端口号,没有则为空 |
| protocol | http: | 使用的协议 |
| search | ?q=javascript | url的查询字符串,通常为?后面的内容 |
# navigator
获取浏览器属性
# history
- history.go()
- history.back()
- history.forward()
- history.length
# screen
客户显示器的信息
上次更新: 2021/12/19, 18:05:42