浏览器对象模型 (BOM) 使 JavaScript 有能力与浏览器“对话”。
浏览器对象模型 (BOM)
浏览器对象模型(Browser Object Model)尚无正式标准。
由于现代浏览器已经(几乎)实现了 JavaScript 交互性方面的相同方法和属性,因此常被认为是 BOM 的方法和属性。
Window 对象
所有浏览器都支持 window 对象。它表示浏览器窗口。
所有 JavaScript 全局对象、函数以及变量均自动成为 window 对象的成员。
全局变量是 window 对象的属性。
全局函数是 window 对象的方法。
甚至 HTML DOM 的 document 也是 window 对象的属性之一:
window.document.getElementById("header");
与此相同:
document.getElementById("header");
Window 尺寸
有三种方法能够确定浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条)。
对于Internet Explorer、Chrome、Firefox、Opera 以及 Safari:
- window.innerHeight - 浏览器窗口的内部高度
- window.innerWidth - 浏览器窗口的内部宽度
对于 Internet Explorer 8、7、6、5:
- document.documentElement.clientHeight
- document.documentElement.clientWidth
或者
- document.body.clientHeight
- document.body.clientWidth
实用的 JavaScript 方案(涵盖所有浏览器):
实例
var w=window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h=window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
该例显示浏览器窗口的高度和宽度:(不包括工具栏/滚动条)
其他 Window 方法
一些其他方法:
- window.open() - 打开新窗口
- window.close() - 关闭当前窗口
- window.moveTo() - 移动当前窗口
- window.resizeTo() - 调整当前窗口的尺寸
http://gou.aigou.com/dog/1383167.htmlhttp://gou.aigou.com/dog/1383160.htmlhttp://gou.aigou.com/dog/1382969.htmlhttp://gou.aigou.com/dog/1382929.htmlhttp://gou.aigou.com/dog/1382928.htmlhttp://gou.aigou.com/dog/1382927.htmlhttp://gou.aigou.com/dog/1382926.htmlhttp://gou.aigou.com/dog/1382924.htmlhttp://gou.aigou.com/dog/1382921.htmlhttp://gou.aigou.com/dog/1382919.htmlhttp://gou.aigou.com/dog/1382915.htmlhttp://gou.aigou.com/dog/1382912.htmlhttp://gou.aigou.com/dog/1382905.htmlhttp://gou.aigou.com/dog/1382899.htmlhttp://gou.aigou.com/dog/1382890.htmlhttp://gou.aigou.com/dog/1382884.htmlhttp://gou.aigou.com/dog/1382875.htmlhttp://gou.aigou.com/dog/1382874.htmlhttp://gou.aigou.com/dog/1382840.htmlhttp://gou.aigou.com/dog/1382835.htmlhttp://gou.aigou.com/dog/1382725.htmlhttp://gou.aigou.com/dog/1382721.htmlhttp://gou.aigou.com/dog/1382718.htmlhttp://gou.aigou.com/dog/1373883.htmlhttp://gou.aigou.com/dog/1373781.htmlhttp://gou.aigou.com/dog/1373775.htmlhttp://gou.aigou.com/dog/1373769.htmlhttp://gou.aigou.com/dog/1373168.htmlhttp://gou.aigou.com/dog/1373169.htmlhttp://gou.aigou.com/dog/1373152.htmlhttp://gou.aigou.com/dog/1373141.htmlhttp://gou.aigou.com/dog/1372827.htmlhttp://gou.aigou.com/dog/1372824.htmlhttp://gou.aigou.com/dog/1372493.htmlhttp://gou.aigou.com/dog/1372483.htmlhttp://gou.aigou.com/dog/1372345.htmlhttp://gou.aigou.com/dog/1372344.htmlhttp://gou.aigou.com/dog/1372297.htmlhttp://gou.aigou.com/dog/1372294.htmlhttp://gou.aigou.com/dog/1372250.htmlhttp://gou.aigou.com/dog/1372247.htmlhttp://gou.aigou.com/dog/1372235.htmlhttp://gou.aigou.com/dog/1371550.htmlhttp://gou.aigou.com/dog/1371541.htmlhttp://gou.aigou.com/dog/1371540.htmlhttp://gou.aigou.com/dog/1371539.htmlhttp://gou.aigou.com/dog/1371505.htmlhttp://gou.aigou.com/dog/1371502.htmlhttp://gou.aigou.com/dog/1371498.htmlhttp://gou.aigou.com/dog/1371465.htmlhttp://gou.aigou.com/dog/1371461.htmlhttp://gou.aigou.com/dog/1371448.htmlhttp://gou.aigou.com/dog/1371442.htmlhttp://gou.aigou.com/dog/1371430.htmlhttp://gou.aigou.com/dog/1371425.htmlhttp://gou.aigou.com/dog/1371417.htmlhttp://gou.aigou.com/dog/1371416.htmlhttp://gou.aigou.com/dog/1371407.htmlhttp://gou.aigou.com/dog/1371402.htmlhttp://gou.aigou.com/dog/1371388.htmlhttp://gou.aigou.com/dog/1371386.htmlhttp://gou.aigou.com/dog/1371306.htmlhttp://gou.aigou.com/dog/1371266.htmlhttp://gou.aigou.com/dog/1371262.htmlhttp://gou.aigou.com/dog/1371250.htmlhttp://gou.aigou.com/dog/1371238.htmlhttp://gou.aigou.com/dog/1368640.htmlhttp://gou.aigou.com/dog/1368574.htmlhttp://gou.aigou.com/dog/1356454.htmlhttp://gou.aigou.com/dog/1356333.htmlhttp://gou.aigou.com/dog/1400497.htmlhttp://gou.aigou.com/dog/1400492.htmlhttp://gou.aigou.com/dog/1400487.htmlhttp://gou.aigou.com/dog/1400482.htmlhttp://gou.aigou.com/dog/1400477.htmlhttp://gou.aigou.com/dog/1400472.htmlhttp://gou.aigou.com/dog/1400469.htmlhttp://gou.aigou.com/dog/1400466.htmlhttp://gou.aigou.com/dog/1400461.htmlhttp://gou.aigou.com/dog/1400456.htmlhttp://gou.aigou.com/dog/1400452.htmlhttp://gou.aigou.com/dog/1400445.htmlhttp://gou.aigou.com/dog/1400434.htmlhttp://gou.aigou.com/dog/1400423.htmlhttp://gou.aigou.com/dog/1400410.htmlhttp://gou.aigou.com/dog/1400399.htmlhttp://gou.aigou.com/dog/1400387.htmlhttp://gou.aigou.com/dog/1400371.htmlhttp://gou.aigou.com/dog/1400358.htmlhttp://gou.aigou.com/dog/1400345.htmlhttp://gou.aigou.com/dog/1400331.htmlhttp://gou.aigou.com/dog/1400316.htmlhttp://gou.aigou.com/dog/1400299.htmlhttp://gou.aigou.com/dog/1400288.htmlhttp://gou.aigou.com/dog/1400277.htmlhttp://gou.aigou.com/dog/1400258.htmlhttp://gou.aigou.com/dog/1400235.htmlhttp://gou.aigou.com/dog/1400213.htmlhttp://gou.aigou.com/dog/1400192.htmlhttp://gou.aigou.com/dog/1400172.htmlhttp://gou.aigou.com/dog/1400152.htmlhttp://gou.aigou.com/dog/1400129.htmlhttp://gou.aigou.com/dog/1400110.htmlhttp://gou.aigou.com/dog/1400094.htmlhttp://gou.aigou.com/dog/1400072.htmlhttp://gou.aigou.com/dog/1400058.htmlhttp://gou.aigou.com/dog/1400042.htmlhttp://gou.aigou.com/dog/1400024.htmlhttp://gou.aigou.com/dog/1400008.htmlhttp://gou.aigou.com/dog/1399993.htmlhttp://gou.aigou.com/dog/1399974.htmlhttp://gou.aigou.com/dog/1399960.htmlhttp://gou.aigou.com/dog/1399945.htmlhttp://gou.aigou.com/dog/1399932.htmlhttp://gou.aigou.com/dog/1399920.htmlhttp://gou.aigou.com/dog/1399903.htmlhttp://gou.aigou.com/dog/1399890.htmlhttp://gou.aigou.com/dog/1399852.htmlhttp://gou.aigou.com/dog/1399834.htmlhttp://gou.aigou.com/dog/1399805.htmlhttp://gou.aigou.com/dog/1399774.htmlhttp://gou.aigou.com/dog/1399718.htmlhttp://gou.aigou.com/dog/1399686.htmlhttp://gou.aigou.com/dog/1399640.htmlhttp://gou.aigou.com/dog/1399612.htmlhttp://gou.aigou.com/dog/1399582.htmlhttp://gou.aigou.com/dog/1399539.htmlhttp://gou.aigou.com/dog/1399514.htmlhttp://gou.aigou.com/dog/1399482.htmlhttp://gou.aigou.com/dog/1399451.htmlhttp://gou.aigou.com/dog/1399415.htmlhttp://gou.aigou.com/dog/1399382.htmlhttp://gou.aigou.com/dog/1399346.htmlhttp://gou.aigou.com/dog/1399294.htmlhttp://gou.aigou.com/dog/1399246.htmlhttp://gou.aigou.com/dog/1399203.htmlhttp://gou.aigou.com/dog/1399162.htmlhttp://gou.aigou.com/dog/1399124.htmlhttp://gou.aigou.com/dog/1399086.htmlhttp://gou.aigou.com/dog/1399039.htmlhttp://gou.aigou.com/dog/1399032.htmlhttp://gou.aigou.com/dog/1398982.htmlhttp://gou.aigou.com/dog/1398961.htmlhttp://gou.aigou.com/dog/1398906.htmlhttp://gou.aigou.com/dog/1398873.htmlhttp://gou.aigou.com/dog/1398832.htmlhttp://gou.aigou.com/dog/1398796.htmlhttp://gou.aigou.com/dog/1398734.htmlhttp://gou.aigou.com/dog/1398673.htmlhttp://gou.aigou.com/dog/1398624.htmlhttp://gou.aigou.com/dog/1398578.htmlhttp://gou.aigou.com/dog/1398521.htmlhttp://gou.aigou.com/dog/1398483.htmlhttp://gou.aigou.com/dog/1398448.htmlhttp://gou.aigou.com/dog/1398419.htmlhttp://gou.aigou.com/dog/1398387.htmlhttp://gou.aigou.com/dog/1398359.htmlhttp://gou.aigou.com/dog/1398315.htmlhttp://gou.aigou.com/dog/1398284.htmlhttp://gou.aigou.com/dog/1398253.htmlhttp://gou.aigou.com/dog/1398222.htmlhttp://gou.aigou.com/dog/1398191.htmlhttp://gou.aigou.com/dog/1396517.htmlhttp://gou.aigou.com/dog/1396477.htmlhttp://gou.aigou.com/dog/1396428.htmlhttp://gou.aigou.com/dog/1396395.htmlhttp://gou.aigou.com/dog/1396363.htmlhttp://gou.aigou.com/dog/1396321.htmlhttp://gou.aigou.com/dog/1396286.htmlhttp://gou.aigou.com/dog/1396244.htmlhttp://gou.aigou.com/dog/1396209.htmlhttp://gou.aigou.com/dog/1396179.htmlhttp://gou.aigou.com/dog/1396147.htmlhttp://gou.aigou.com/dog/1396116.htmlhttp://gou.aigou.com/dog/1396083.htmlhttp://gou.aigou.com/dog/1396065.htmlhttp://gou.aigou.com/dog/1396039.htmlhttp://gou.aigou.com/dog/1396018.htmlhttp://gou.aigou.com/dog/1396004.htmlhttp://gou.aigou.com/dog/1395987.htmlhttp://gou.aigou.com/dog/1395967.htmlhttp://gou.aigou.com/dog/1395942.htmlhttp://gou.aigou.com/dog/1395907.htmlhttp://gou.aigou.com/dog/1395861.htmlhttp://gou.aigou.com/dog/1395811.htmlhttp://gou.aigou.com/dog/1395786.htmlhttp://gou.aigou.com/dog/1395760.htmlhttp://gou.aigou.com/dog/1395731.htmlhttp://gou.aigou.com/dog/1395704.htmlhttp://gou.aigou.com/dog/1395679.htmlhttp://gou.aigou.com/dog/1395653.htmlhttp://gou.aigou.com/dog/1395632.htmlhttp://gou.aigou.com/dog/1395608.htmlhttp://gou.aigou.com/dog/1395582.htmlhttp://gou.aigou.com/dog/1395551.htmlhttp://gou.aigou.com/dog/1395529.htmlhttp://gou.aigou.com/dog/1394588.htmlhttp://gou.aigou.com/dog/1394564.htmlhttp://gou.aigou.com/dog/1393869.htmlhttp://gou.aigou.com/dog/1393779.htmlhttp://gou.aigou.com/dog/1393764.htmlhttp://gou.aigou.com/dog/1393754.htmlhttp://gou.aigou.com/dog/1393730.htmlhttp://gou.aigou.com/dog/1393722.htmlhttp://gou.aigou.com/dog/1393708.htmluser.qzone.qq.com/2116849426user.qzone.qq.com/2623181969user.qzone.qq.com/2261698522user.qzone.qq.com/2783361544user.qzone.qq.com/2040135481user.qzone.qq.com/2776380562user.qzone.qq.com/2096326895user.qzone.qq.com/2384971862user.qzone.qq.com/2405523673user.qzone.qq.com/2782349357user.qzone.qq.com/253132414shangyufeng01.blog.163.com/shangyufeng02.blog.163.com/shangyufeng03.blog.163.com/shangyufeng04.blog.163.com/shangyufeng05.blog.163.com/shangyufeng06.blog.163.com/shangyufeng07.blog.163.com/shangyufeng08.blog.163.com/shangyufeng09.blog.163.com/shangyufeng10.blog.163.com/blog.sina.com.cn/u/3723033445blog.sina.com.cn/u/3723327795blog.sina.com.cn/u/3700819357blog.sina.com.cn/u/3723077630j.map.baidu.com/Ar3Phj.map.baidu.com/HzePhzhuanshuyu.blog.tianya.cn/shangyufeng01.blog.163.com/bjhhdxbyy.blog.tianya.cnwww.dama2.com/index/ureg?tj=408494&vali=1b35bdf09db27817dd3060b619ea54e6