首页 > 编程语言 > 详细

使用JavaScript设置、获取父子页面中的值

时间:2016-05-18 12:08:19      阅读:172      评论:0      收藏:0      [点我收藏+]
  • 一:获取父页面中的值

有二种方法windows.open()和windows.showModalDialog()

 

1.windos.open(URL,name,reatures,replace)

再父页面中 fatherPage.aspx

<script type="text/javascript">

  function a(){

    windows.open("sonPage.aspx")

  }

</script>

在子页面(sonPage.aspx)中获取父页面中的对象、值

<script type="text/javascript">

var text=windows.opener.document.getElementById("TextBox1").value;

alert(text)

</script>

2.windows.showModalDialog(URL,name,??,??,??)

在父页面中

<script language="javascript">
function popwindow(){
window.showModalDialog(sonPage.aspx‘,window);
}
</script>

在子页面中获取值

<script language="javascript">
var vwin = window.dialogArguments; //得到window参数
var doc = vwin.document.getElementById("TextBox1").value; //获得TextBox的值
alert(doc);
</script>

  • 在父页面中获取子页面回传的值

 

使用JavaScript设置、获取父子页面中的值

原文:http://www.cnblogs.com/yuanyanyan/p/5497930.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!