• iframe中 父页面和子页面查找元素的方法


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

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

    jQuery:

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

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

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

    jQuery:

    1. $([window.]parent) //查找父页面的window对象  
    2. $([window.]parent.document) //查找父页面的document对象  
    3. $([window.]parent.document.body) //查找父页面的body对象  
    4. $([window.]parent.document.body).find('#button') //查找父页面中id为button的对象  

    注:[window.] 代表可加可不加。

  • 相关阅读:
    CCNP路由实验(4) -- BGP
    CCNP路由实验(3) -- 路由控制
    CCNP路由实验(2) -- OSPF
    什么是依赖注入
    java中接口的定义与实现
    火炬之光模型导出(Unity载入火炬之光的模型)
    【创新培育项目】为什么要组队參加比赛?及如何寻找一个合适的选题?
    oracle中schema指的是什么?
    介绍自己上架的第一个游戏
    unity 打包资源及网络请求资源包
  • 原文地址:https://www.cnblogs.com/dengshaojun/p/4113068.html
Copyright © 2020-2023  润新知