zoukankan      html  css  js  c++  java
  • iframe 父子页面之间取值

    父页面

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     5     <title>iframe父子页面取值</title>
     6     <script type="text/javascript">
     7         function say() {
     8             alert("parent");
     9         }
    10         function callChild() {
    11             //document.frames["myFrame"].window.say();//只适用于ie浏览器
    12             myFrame.window.say();
    13             myFrame.window.document.getElementById("button").value = "我变了";
    14         }
    15     </script>
    16 </head>
    17 <body>
    18 <input type=button value="调用child.html中的函数say()" onclick="callChild()">
    19 <iframe name="myFrame" src="b_2.html"></iframe>
    20 </body>
    21 </html> 

    子页面

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     5     <title>iframe父子页面取值</title>
     6     <script type="text/javascript">
     7         function say() {
     8             alert("child");
     9         }
    10         function callParent() {
    11             parent.say();
    12             parent.window.document.getElementsByName("myFrame")[0].style.height = "100px";
    13         }
    14     </script>
    15 </head>
    16 <body>
    17 <input id="button" type=button value="调用parent.html中的say()函数" onclick="callParent()">
    18 </body>
    19 </html> 
  • 相关阅读:
    转:测试驱动开发全攻略
    转:如何提高自己的归纳总结能力?
    转:从编译链接过程解析static函数的用法
    C++ 不能在类体外指定关键字static
    转:画图解释 SQL join 语句
    转:[置顶] 从头到尾彻底理解KMP(2014年8月22日版)
    转:The Knuth-Morris-Pratt Algorithm in my own words
    转:数组与指针的区别
    删除单链表中间节点
    如果判断两个单链表有交?第一个交点在哪里?
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2391848.html
Copyright © 2011-2022 走看看