`
daidalei321
  • 浏览: 109455 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

js实现子页面向父页面传值

    博客分类:
  • js
阅读更多

1、父页面father.html

 

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>将值返回父页面</title>
 <script type="text/javascript">
     function acceptValueFromSon()
    {         

             window.open ('son.html','','status=no,scrollbars=no,top=20,

              left=110,width=420,height=165');
     }

 </script>
  </head>
 
  <body>
   <input type="text" name="elementName" id="elementName"/>
   <input type="button" value="跳到子页面" onclick="acceptValueFromSon();"/>
  </body>
</html>

 

2、子页面son.html

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>将值返回父页面</title>
 <script type="text/javascript">
     function returnValueToFather()
     {
         var ValueToFather=document.getElementById("preturnValue").value;
         window.opener.document.getElementById("elementName").value=ValueToFather;
         window.close();
     }

 </script>
  </head>
 
  <body>
   <input type="text" name="preturnValue" id="preturnValue"/>
   <input type="button" value="提交" onclick="returnValueToFather();"/>
  </body>
</html>

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics