zoukankan      html  css  js  c++  java
  • jquery iframe 父子互操作

    父页面

    View Code
    <html>
    <head>
    <script src="jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(
    function(){
    $(
    "#btn").click(function(){
        
    var sondocument = $(window.frames[0].document)
        alert(sondocument.find(
    "#smsg").html());
    })});
    </script>
    </head>
    <body>
    <div>below me it is an iframe</div>
    <iframe id="myiframe" src="son.html" width="300px;" height="500px;"></iframe>
    <div id="mm">if you see me through alert from an son's button,you win!</div>
    <input type="button" id="btn" value="click me "/>


    </body>
    </html>

     子页面

    View Code
    <html>
    <head>
    <script src="jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(
    function(){
    $(
    "#btn").click(function(){
        
    var mm = $('#mm', window.parent.document)
        alert(mm.html())    
    })});
    </script>
    </head>
    <body>
    <input type="button" id="btn" value="click me "/>
    <div>click the button above to get parent element's innerHTML</div>
    <div id="smsg">if you see me in the alert msg,you win</div>
    </body>
    </html>



  • 相关阅读:
    mysql日常~gh-ost使用
    redis基础篇~哨兵
    zeppelin-0.6.0安装配置
    spark 好文链接
    spark API 介绍链接
    solr5.5 基于内置jetty配置 Ubuntu
    Gollum 安装笔记
    手机版测试
    win7 eclipse 调试storm
    (转)Storm UI 解释
  • 原文地址:https://www.cnblogs.com/applesuch5/p/2150128.html
Copyright © 2011-2022 走看看