zoukankan      html  css  js  c++  java
  • HTML中嵌套的子frame如何访问父页面中的函数?

    我解决的办法,在父页面写了个函数,然后在frame页面调用父页面的函数,具体代码如下:

    父:function a(){}

    子frame:window.parent.a();

    问题迎刃而解,2020/04/20日补记:如果frame中的页面和父页面不同域。则需要进行跨域实现js代码互相调用。这种情况,往document.domain方向去调查。

     https://www.jb51.net/article/39486.htm

    参考1:http://m.php.cn/article/383528.html

    参考2:https://www.jb51.net/article/116273.htm

    附件:

    DOM方法:
    父窗口操作IFRAME:window.frames["iframeSon"].document
    IFRAME操作父窗口: window.parent.document

    jquery方法:
    在父窗口中操作 选中IFRAME中的所有输入框: $(window.frames["iframeSon"].document).find(":text");
    在IFRAME中操作 选中父窗口中的所有输入框:$(window.parent.document).find(":text");
    iframe框架的HTML:<iframe src="test.html" id="iframeSon" width="700″ height="300″ frameborder="0″ scrolling="auto"></iframe>

    1.在父窗口中操作 选中IFRAME中的所有单选钮
    $(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");

    2.在IFRAME中操作 选中父窗口中的所有单选钮
    $(window.parent.document).find("input[@type='radio']").attr("checked","true");
    iframe框架的:

    <iframe src="test.html" id="iframe1″ width="700″ height="300″ frameborder="0″ scrolling="auto"></iframe>

    1.在父窗口中操作 选中IFRAME中的所有单选钮
    $(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");

    2.在IFRAME中操作 选中父窗口中的所有单选钮
    $(window.parent.document).find("input[@type='radio']").attr("checked","true");
    iframe框架的:<iframe src="test.html" id="iframe1" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
    IE7中测试通过

    Best Regards
  • 相关阅读:
    多个相同结构的表的字段的修改、添加
    SQL SERVER 查询去重 PARTITION BY
    message from server: "Host 'xxx' is not allowed to connect to th
    jdk 1.8 连接数据库
    恢复SQLServer数据库后,如何同步登陆名和用户名
    无法识别的属性“targetFramework”。请注意属性名称区分大小写。错误解决办法
    jquery.tablesorter 使用
    MD5加密
    C# 判断是否是节假日
    word ladder
  • 原文地址:https://www.cnblogs.com/pecool/p/9192679.html
Copyright © 2011-2022 走看看