详细介绍JavaScript静态页面值传递之Window.open [ 网站地图 ]

发表于:2009-12-14 浏览:58 作者: 来源:互联网

关键字:JavaScript,Window.open

描述:Window.open篇  这两窗口之间存在着关系.父窗口parent.htm打开子窗口son.htm   子窗口可以通过window.opener指向父窗口.这样可以访问父窗口的对象.   Post.htm <inputtype=textname=maintext&

Window.open篇
  这两窗口之间存在着关系.父窗口parent.htm打开子窗口son.htm

  子窗口可以通过window.opener指向父窗口.这样可以访问父窗口的对象.

  Post.htm

<input type=text name=maintext>
<input type=button value="Open">
Read.htm
<script language="javascript" >
//window.open打开的窗口.
//利用opener指向父窗口.
var parentText = window.opener.document.all.maintext.value;
alert(parentText);
</script>

  优点:取值方便.只要window.opener指向父窗口,就可以访问所有对象.

    不仅可以访问值,还可以访问父窗口的方法.值长度无限制.

  缺点:两窗口要存在着关系.就是利用window.open打开的窗口.不能跨域.


站长资讯网 做中国最丰富的资讯网站 沪ICP备05004089号