BOM体系结构

来源:互联网 发布:棋牌类游戏算法 编辑:程序博客网 时间:2024/05/17 01:20

 BOM(Browser Object Model)由一系列相关的对象构成

window对象是整个BOM的核心,所有对象和集合都以某种方式回接到window对象

window
window对象是浏览器或者框架自身.top总是浏览器,parent是父框架,self表示自己. window通常可以省略.
窗口操作: moveBy(dx, dy), moveTo(x, y), resizeBy(dw, dh), resizeTo(w, h).
导航: window.open(url, frame name, attribute). attribute可以是left, top, height, width, resizable, scrollable, toolbar, status, location(all default no). 
window.open 返回新窗口引用,并且有一个opener对象表示父窗口
window.close.
对话框: alert, confirm, prompt.
状态栏: window.status, window.defaultStatus
时间间隔和暂停: timeoutId = setTimeout("alert('hello world')", 1000); clearTimeout(timeoutId);类似有setInterval和clearInterval.
历史: window.history.go(+-n), history.back, history.forward. history.length

document

alert(window.document == document) == true. 他是唯一一个既属于DOM又属于BOM的对象
属性:title, URL, referrer, lastModified
集合属性: anchors, applets, embeds, forms, images, links.
方法: write, writeln. 必须在完全载入页面前调用write()和writeln()方法. 如果任何一个方法是在页面载入后调用的,它将抹去页面的内容,显示指定的内容.

location
window和 document的属性,相互等价.
属性: hash(位于#后面的东西), host, hostname, href, pathname, port, protocol, search(位于?后面的东西).
方法: assign(), replace(), reload(false=从缓存中导入(default),true=从服务器端导入)
navigator和 screen对象
navigator对象表示了浏览器本身,可以获取一些属性,但是各个浏览器支持不同.
screen 对象可以得到用户系统的信息,如availHeight, availWidth(可用屏幕宽度和高度,排除了系统任务栏), colorDepth, height, width.


原创粉丝点击