在最近开发的web项目中,经常用到页面中嵌套很多的页面,页面间的传值。
现在总结如下:
1.window.self就表示当前打开的窗口
2.window.top就表示最顶层的窗口(假如说你在一个窗口里面有嵌套了其他一些窗口,那么top就表示这个最顶层的窗口)
3.window.parent----是iframe页面调用父页面对象
举例;
a.html
<html>
<head><title>父页面</title></head>
<body>
<form name="form1" id="form1">
<input type="text" name="username" id="username"/>
</form>
<iframe src=\'#\'" width=100%></iframe>
</body>
</html>
需求:如果我们要在b.html中要对a.html中username文本框赋值,
就如很多上传功能,上传功能也在Iframe中,上传成功后把上传后
的路径放到父页面中文本框中去。

那我们就应该在b.html中写;
<script type="text/javaScript>
var _parentWin=window.parent;
_parentWin.form1.username.value="xxxx";
</script>

4.window.opener----是window.open打开的子页面对象调用父页面对象
self代表自身窗口,是对当前window对象的引用,与window属性同义
opener:代表打开自身的那个窗口,比如窗口A打开窗口B,如果靠window.open方法,
则对于窗口B,self代表B自己,而opener窗口代表A


Parent对象、Frame对象、Document对象和Form对象的阶层关系-----id
Window对象→Parent对象→Frame对象→Document对象→Form对象,如下:
parent.frame1.document.forms[0].elements[0].value;

参考http://www.cnblogs.com/wangdaye/archive/2010/05/03/1726518.html