17、常用的 BOM

57 阅读1分钟

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浏览器所属设备的可用高度(减掉系统的上下任务栏宽高)