17、常用的 BOM

location
location.assgin(url)跳转页面,创建新的浏览器历史,等价于location.href = url
location.replace(url)跳转页面, 替换当前的浏览器历史
location.reload()刷新当前页面

history
history.pushState(state, title, url)跳转页面,创建新的浏览器历史,但不刷新页面
history.replaceState(state, title, url)跳转页面,替换当前的浏览器历史,但不刷新页面
history.back()后退一步
history.forward()前进一步
history.go(number)跳到 n 步

navigator
navigator.useAgent获取当前浏览器的信息
navigator.useAgentData获取当前浏览器的信息,更详细

screen
screen.width/height浏览器所属设备的宽高
screen.availWidth/availHeight浏览器所属设备的可用高度(减掉系统的上下任务栏宽高)


17、常用的 BOM
https://mrhzq.github.io/职业上一二事/前端面试/每日知识卡片/17、常用的 BOM/
作者
黄智强
发布于
2024年2月3日
许可协议