zoukankan      html  css  js  c++  java
  • JQuery操作iframe父页面与子页面的元素与方法

    下面简单使用Jquery来操作iframe的一些记录,这个使用纯JS与可以实现。

    第一、在iframe中查找父页面元素的方法:
    $('#id', window.parent.document)

    第二、在父页面中获取iframe中的元素方法:
    $(this).contents().find("#suggestBox")

    第三、在iframe中调用父页面中定义的方法和变量:
    parent.method
    parent.value

    iframe里用jquery获取父页面body

    iframe.html


    <html>
    <script src='jquerymin.js'>
    </script>
    <body id='1'>
        <div>it is a iframe</div>
    </body>    
    <script>
        $(document).ready(
            function()
            {
               
            var c = $(window.parent.document.body) //麻烦的方法: var c = $($(window).eq(0)[0].parent.document).find('body'); ,忘了可以用前面的方法了
                
            alert(c.html());
            }
        );
        
    </script>
    </html>
  • 相关阅读:
    bat 批处理编写
    dos 命令
    反射
    反爬机制和破解方法汇总
    pandas
    谷歌历史浏览器下载
    python-----pip安装源选择(亲测有效)
    deepin 20.1 系统未安装pip
    python自带库-----os.path
    python 自带库---os库
  • 原文地址:https://www.cnblogs.com/buffer/p/1925774.html
Copyright © 2011-2022 走看看