Javascript浏览器对象模型(BOM)

Javascript浏览器对象模型(BOM)

 

CSSER整理,如有疑问请联系。

BOM指(Brower Object Model)浏览器对象模型。

window对象的属性:

document frames history location navigator screen

document对象的属性:

anchors forms images links location

window对象

观察BOM的体系结构,所有的对象都源自window对象,它表示整个浏览器窗口。

Frame实际是个array,如果窗口分祯的话,每个frame相当一个单独的window对象,如window.frames[0](注意,top对象的使用,top永远指向最外层的祯,top.frames[0], 因为当你的代码被包括在某个frame中是,这时候window指向的是当前祯,这也许不是你的原意,所以尽量使用top来避免错误)

parent ,self,top,window的关系:

parent:如果当前窗口为frame,指向包含该frame的窗口的frame (frame)

self :指向当前的window对象,与window同意。 (window对象)

top :如果当前窗口为frame,指向包含该frame的top-level的window对象

window :指向当前的window对象,与self同意。

window的有用属性/对象与方法

大小与移动:

moveBy,moveTo,resizeBy,resizeTo;

打开popup窗口:

open;

系统提示窗:

alert(),confirm(),prompt;

状态栏:

Status,defaultStatus;

时间间隔:

setTimeout(),setInterval;

历史纪录:

history.go(-1)后退

document对象

唯一BOM和DOM都有的对象。从BOM的角度看,侧重于从集合的角度看问题,把页面划分为不同的部分,以及页面本身的一些属性,如背景色,标题名称等,由于BOM的实现是基于浏览器的,所以不同浏览器的属性和方法有不一致之处,这造成很多麻烦。注意一些一致的,常用的属性和方法,BOM把页面分为如下几部分:

anchors : Collection of all anchors in the page(represented by <a name="anchorname"></a>)

applets : Collection of all applets in the page

forms : Collection od all embeded objects in the page(represented by the <embed /> tag)

images : Collection of all forms in the page

links : Collection of all links in the page (represented by <a href="somewhere.htm"></a>)

location 对象

指浏览器窗口中输入的URL,它有很多属性,即把URL拆为了很多部分,分别表示之,如href,host,port,pathname等

Navigator对象

更加针对浏览器,举一些IMOS都有的例子如appCodeName,appName, userAgent等

Screen对象

这个Screen指的是客户计算机的屏幕,如我的机器的Screen.Heigh和Width为768X1024,例如可以用这个属性将浏览器置为全屏:

window.moveTo(0, 0);

window.resizeTo(screen.availWidth, screen.availHeight);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值