DHTMLX Docs & Samples Explorer

Access IFRAME Content

IFRAME content is a result of attaching URLs into layout/windows.

The follownig code is a code of attached page inner.html

    <html>
    <head>
        <script>
            var msg = "";
            function myFunc() {
                alert(msg);
            }
        </script>
    </head>
    <body>
        <div id="myDiv"> </div>
    </body>
    </html>

Page where page inner.html will attached

    // windows
    var w1 = dhxWins.createWindow(id, x ,y, w, h);
    w1.attachURL("inner.html");
    // layout
    dhxLayout.cells(id).attachURL("inner.html");
    // accordion
    dhxAcc.cells(id).attachURL("inner.html");
    // tabbar
    dhxTabbar.cells(id).attachURL("inner.html");

Accessing IFRAME object

    var ifr;
    // windows
    ifr = dhxWins.window(id)._frame;
    // layout
    ifr = dhxLayout.cells(id)._frame;
    // accordion
    ifr = dhxAcc.cells(id)._frame;
    // tabbar
    ifr = dhxTabbar.cells(id)._frame;

Accessing functions/variables/obects

    ifr.contentWindow.msg = "Popup message";
    ifr.contentWindow.myFunc();
    ifr.contentWindow.document.getElementById("myDiv").innerHTML = "Object on page";