BOM

Q:BOM是什么?

A:“浏览器对象模型”。是Web中使用JS的核心。(而ECMAScript是JavaScript的核心)。

 

Q:window对象与全局变量有差别吗?

A:全局变量不能通过delete操作符删除,而直接在windows对象上的定义的属性可以。

var age = 29;
window.color = "red";

delete window.age; //age不是全局变量,false
delete window.color; //true

alert(window.age); //29
alert(window.color); //undefined

 

确定窗口位置的属性和方法:

1.screenLeft 和 screenTop( 有没有相对应的screenRight和screenBottom??)

var leftPos = (typeof window.screenLeft == "number")?window.screenLeft :window.screenX;
var topPos = (typeof window.screenTop == "number")?window.screenTop :window.screenY;
alert(leftPos);
alert(topPos);

2.moveBy() 和 moveTo()方法

moveBy() 接收 在水平和垂直方向上移动的像素数 , moveTo() 接收新位置的x和y坐标值。(但是这两个货可能会被浏览器禁用~)注意:只能对最外层的window对象使用。

 

窗口大小

1.视口 vs 浏览器窗口

视口:viewpoint 单个标签页对应的浏览器窗口

innerWidth,innerHeight,outerWidth,outerHeight 

document.documentElement.clientWidth 和  document.documentElement.clientHeight(保存页面视口的信息)

注意:IE6特殊,只在标准模式下取得(通过 document.compatMode来确定页面是否处于标准模式)如果是混杂模式,必须通过 document.body.clientWidth 和 document.body.clientHeight取得相同信息。

posted @ 2017-05-05 21:44  SingSingaSong  阅读(208)  评论(0编辑  收藏  举报