window 作用 :js通过window访问浏览器
全局变量、函数与window对象的区别:
在全局作用域声明的全局变量 函数 都成为了window的属性和方法,可用window引用;
但是全局变量没有delete操作,window属性有delete操作
例如:
var age = 29;
wndow.color ="red";
delete window.color;
delete window.age;
alert(window.age)//29
alert(window.color);//undefined;
窗口关系和框架:
window对象保存在frames集合中通过数值索引来访问响应的window对象,每个window对象都有一个name属性
例子:
<frameset>
<frame name="topframe"></frame>
<frameset>
<frame name="leftframe"></frame>
<frame name="rightframe"></frame>
</frameset>
<frame></frame>
</frameset>
想访问某个frame: 使用window.frames["topframe"]来引用;也可以 使用top.frames[0]
top和window、parent、self区别:
top对象始终只想最高层的框架,也就是浏览器窗口;
window只是指向当前编写代码所在框架。
parent对象始终指向当前框架的上层框架
self对象它始终指向window
这些对象都是window的属性,所以可以用window.parent和window.top来访问上层和顶层,所以可以连起来访问如window.parent.parent.frames[0]