• iframe父子页面js之间的调用


    父级页面:mian.html

    子页面1:top.html

    子页面2:index.html

    页面关系

     <div onclick="_top()">调用contentTop页面的alertTop方法</div>
        <iframe id="contentTop" name="contentTop" frameborder="0" th:src="@{/top}" >
            你不支持iframe
        </iframe>
        <iframe id="contentMain" name="contentMain"  frameborder="0" th:src="@{/index}" >
            你不支持iframe
        </iframe>

    父页面调用子页面的方法 (mian.html调用top.html页面的方法)

    js写法 这里的contentTop对应的是iframe的name名

     function _top() {
            contentTop.window.alertTop();
        }

    子页面调用父页面的方法 (top.html调用frame.html的方法)

    在top.html页面写

    <div id="_click">调用父级页面的show()方法</div>

    js写法

    $("#_click").on('click',function () {
            parent.show();
        })

    子页面调用子页面的方法 (top.html调用index.html中的方法)  这有个要求 就是top.html和index.html要同时都显示出来

     <div onclick="_top_index()">调用index.html的_index()方法</div>

    js写法 (这里的contentMain对应的是frame.html中index.html的name名)

    function _top_index() {
            parent.contentMain._index();
        }
    -----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------ (蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)
  • 相关阅读:
    开源项目之Android StandOut(浮动窗口)
    小智慧7
    安卓学习
    asp.net学习Request和Response的其他属性
    bash中的转义
    POJ 1833 排列
    Django点滴(四)ORM对象存取
    POJ 1681 Painter's Problem
    linux2.6.32在mini2440开发板上移植(21)之WebServer服务器移植
    [gkk传智]static与多态及向下向上转型,及多态调用总结
  • 原文地址:https://www.cnblogs.com/pxblog/p/15379520.html
Copyright © 2020-2023  润新知