首页 > Web开发 > 详细

js实现页面传值

时间:2014-07-16 23:39:47      阅读:607      评论:0      收藏:0      [点我收藏+]

今天做东西用到,在网上查到了这样的一种方法,学习学习:

来源:http://bbs.csdn.net/topics/310229114

 

Page1:

<!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>
    <title>无标题页</title>
    <script type="text/javascript">
    function OpenWin()
    {
      window.open("father.htm","aa","","");
    }
    </script>
</head>
<body>
    <input id="T1" type="text" />
    <input id="Button1" type="button" value="提交" onclick="OpenWin();" />
</body>
</html>

 

Page2:

<!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>
    <title>无标题页</title>
    <script type="text/javascript">
    function ReturnVal()
    {
      window.opener.document.getElementById(T1).value=document.getElementById(Text1).value;
      window.close();
    }
    </script>
</head>
<body>
    <input id="Text1" type="text" />
    <input id="Button1" type="button" value="关闭" onclick="ReturnVal();" />
</body>
</html>

 

PS:

使用window.opener可以访问js的变量 :window.opener.变量名

 

 

-------------

js实现页面传值,布布扣,bubuko.com

js实现页面传值

原文:http://www.cnblogs.com/KeenLeung/p/3848722.html

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