码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-05-18 12:09:53      阅读:142      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!