<iframe>传值

父类:

  1. <script>  
  2.  function parentFunction() {  
  3.   alert('function in parent');  
  4.  }  
  5.  function callChild() {  
  6.   child.window.childFunction();  
  7.   /*  
  8.    child 为iframe的name属性值,  
  9.    不能为id,因为在FireFox下id不能获取iframe对象  
  10.   */  
  11.  }  
  12. </script>  
  13. </head>  
  14. <body>  
  15. <input type="button" name="call child"  value="call child" onclick="callChild()"/>  
  16. <br/><br/>  
  17. <iframe name="child" src="./child.html" ></iframe>  
  18. </body>  

 

子类:

 

 

  1. <script>  
  2.  function childFunction() {  
  3.   alert('function in child');  
  4.  }  
  5.  function callParent() {  
  6.   parent.parentFunction();  
  7.  }  
  8. </script>  
  9. </head>  
  10. <body>  
  11. <input type="button" name="call parent" value="call parent" onclick="callParent()"/>  
  12. </body>  
posted @ 2017-12-01 17:10  字帖公子  阅读(139)  评论(0)    收藏  举报