zoukankan      html  css  js  c++  java
  • 父页面与ifram子页面之间调用

    子页面调用父页面标签

    js

      window.parent.document.getElementById("元素id")

    jquery

      window.parent.$('.theme-popover')

    父页面调用子页面标签

    js

      window.frames["iframe的name值"].document.getElementById("iframe中控件的ID")

    jquery

      $("#iframe中的控件ID",document.frames("frame的name").document).click();

    子页面调用父页面的方法或者变量:

        window.parent.方法()或者变量名
        例如:想在子页面中得到 id 为 aaa 的文本框的值
        window.parent.$("#aaa").val();//这种写法的前提是引用了jquery 
        window.parent.getElementById("aaa").value; //js的写法

    父页面调取子页面 

       主要是通过contentWindow定位到子页面

       document.getElementById("childframe").contentWindow.childtest();
       //调取子页面中的 childtest 方法 js 的写法
       var childWindow = $("#addFrame")[0].contentWindow;    //获取子窗体中的对象
       childWindow.formSubmit();     //调取子页面的formSubmit方法 jquery的写法
       //注释:其中 childframe和addFrame 都时iframe的id

  • 相关阅读:
    css实现垂直居中
    js验证输入框
    textarea统计字数
    ajax提交form表单
    JS中的正则表达式
    《遮蔽层的隐藏块》
    2016各大互联网公司前端面试题汇总
    JQ 添加节点和插入节点的方法总结
    [原]CentOS7部署osm2pgsql
    [原]CentOS7部署PostGis
  • 原文地址:https://www.cnblogs.com/webmc/p/11097015.html
Copyright © 2011-2022 走看看