opener.window表示打开它的原框架。
top表示顶部框架,
parent引用包含这个窗口的window对像
例子如下;
a.htm页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function a(url,w,h) {
var x = window.screen.availWidth/2-w;
var y = window.screen.availHeight/2-h;
var str = "height="+h+",width="+h+",top="+y+",left="+x+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no";
window.open(url, "_blank", str);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="atxtName" runat="server" onclick="a('aa.aspx','100','500')"></asp:TextBox>
</div>
</form>
</body>
</html>
aa.html页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function aa() {
opener.window.document.getElementById('atxtName').value = 'txtd';
opener.window.document.bgColor = 'red';
parent.parent.document.bgColor = 'blue';
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="aatxtName" runat="server" onclick='aa()'></asp:TextBox>
</div>
</form>
</body>
</html>