首页 > 技术文章 > javascript bom

10yearsmanong 2020-01-19 14:45 原文

javascript包含(ecmascript"es3,5,6")bom dom

Bom是浏览器对象,全拼为Browser Object Model

Bom包含什么

window包含以下

navigator
location
history
screen
document

打开窗口:window.open("wangyedizhi","-blank/-self");

// url    要打开的地址
// target 新窗口的位置     _blank(默认)  _self (链接到新页面)

关闭窗口:window.close();只能关闭从网页中打开的页面

系统对话框
alert() // 系统弹窗
confirm() // 确认、取消弹窗
prompt() //弹出能输入文本的对话框

定时器 setIiterval 定时器清除 clearInterval
间接 setTimeout 同上 clearTimeout

navigator

navigator对象:包含大量有关Web浏览器的信息,在检测浏览器及操作系统上非常有用

window.navigator.appCodeName //浏览器代码名
window.navigator.appName //浏览器步伐名
window.navigator.appMinorVersion //返回浏览器的次级版本。
window.navigator.cpuClass //cpu类型x86
window.navigator.platform //操作体系类型win32
window.navigator.plugins
window.navigator.opsProfile
window.navigator.userProfile
window.navigator.systemLanguage //客户体系语言zh-cn简体中文

location


location对象:对象包含有关当前 URL 的信息,也可用window.location引用它    
location.replace()重新加载当前文档

location.href //当前载入页面的完整URL  

location.search//设置或返回从问号 (?) 开始的 URL(查询部分)  

location.host //服务器的名字
location.pathname //URL设置或返回当前 URL 的路径部分,如/pictures/index.html
location.hash //设置或返回从井号 (#) 开始的 URL(锚),如#ab'c 

window.onhashchange=function(){
    
    
    
}当hash值改变的时候




location.reload(true | false); //重新载入当前页面,为false时从浏览器缓存中重载,为true时从服务器端重载,默认为false
document.location.reload(URL) //打开新的网页

screen

window.screen.width //屏幕宽度
window.screen.height //屏幕高度
window.screen.availWidth //可用宽度(除去任务栏的高度)
window.screen.availHeight //可用高度(除去任务栏的高度)

history

history.back() //在浏览历史里后退一步
history.forward() //在浏览历史里前进一步
history.go(i) //到汗青详细登记单的第i位

html5里的history:
pushState("","","",)//第一个空:数据 第三个空:地址栏
history.window.onpopstate

document

document.write() //向文档写 HTML 表达式 或 JavaScript 代码

推荐阅读