Sons traditional values iframe element elastic layer of the box

Project, the navigation tree, the right side of the page are nested iframe, the right side pages block elastic layer there can be said to have two iframe frame.

So what is the parent of online query methods are not used. The following methods find their own way:

1, the parent page fetch subpages values:

 top.moreFunLayer = top.layer.open({
                type: 2,
                title: "常用功能",
                area: ["600pt", "150pt"],
                content: './workbench/comUseFunc_add.html',
                success: function(layero, index) {
                    // console.log(index);
                    console.log(layero);
                    console.log(layero[0]);
                    console.log(typeof layero[0]);
                    console.log( $(layero[0]).find("#layui-layer-iframe"+index).contents().find("#btn").val() );
                    console.log(layero[0] instanceof jQuery);
                    console.log(layero[0] instanceof HTMLElement);
                }
            });

2, taking the value of the parent sub-page page

 $("#btn").click(()=>{
            console.log("子页面button触发");
            $(parent.document.getElementsByClassName("J_iframe")[0]).attr("src");
            console.log( $(parent.document.getElementsByClassName("J_iframe")[0]).contents().find("#div").html() );
        })

to sum up:

1, the data sub-pages if they wish to take js parent page, display a page may be provided as a div element, or none of the hidden input box. The data is then assigned to the invisible element, then take the value of the parent sub-page elements of the page.

2, when the element value is taken, there is an intermediate spacing iframe elements, they must first locate the iframe element, then take the iframe element content, re-positioning element.

Guess you like

Origin www.cnblogs.com/smile-fanyin/p/10942918.html