zoukankan      html  css  js  c++  java
  • iframe页面和父页面之间元素查找的方法

    1.从父页面中查找iframe子页面中对象的方法:
    JS:

    document.getElementById('iframe').contentWindow //查找iframe加载的页面的window对象  
    document.getElementById('iframe').contentWindow.document //查找iframe加载的页面的document对象  
    document.getElementById('iframe').contentWindow.document.body //查找iframe加载的页面的body对象  
    document.getElementById('iframe').contentWindow.document.getElementById('icontent') //查找iframe加载的页面的id为icontent的对象 

    jQuery:

    $('#iframe').contents() //查找iframe加载的页面的document对象  
    $('#iframe').contents().find('body') //查找iframe加载的页面的body对象  
    $('#iframe').contents().find('body').find('#icontent') //查找iframe加载的页面的id为icontent的对象

    2.从iframe中查找父页面中对象的方法:

    JS: 

    [window.]parent //查找父页面的window对象  
    [window.]parent.document //查找父页面的document对象  
    [window.]parent.document.body //查找父页面的body对象  
    [window.]parent.document.getElementById('button') //查找父页面中id为button的对象  

    jQuery:

    $([window.]parent) //查找父页面的window对象  
    $([window.]parent.document) //查找父页面的document对象  
    $([window.]parent.document.body) //查找父页面的body对象  
    $([window.]parent.document.body).find('#button') //查找父页面中id为button的对象  
  • 相关阅读:
    CSS3单选动画
    CSS3不一样的下拉选择框
    CSS3实现3d菜单翻转
    CSS3实现加载数据动画2
    CSS3实现加载数据动画1
    MySQL事务隔离级别和Spring事务关系介绍(转载)
    Elasticsearch7.5&Kibana7.5安装
    用nginx实现https请求转http请求(转)
    elasticsearch中多个字段聚合两种方法介绍
    window 同时安装python2和python3
  • 原文地址:https://www.cnblogs.com/kelly007/p/5072087.html
Copyright © 2011-2022 走看看