JavaScript: about the pop-up window across iframe

index.html

<html>
<head>
<script type="text/javascript" src="easyui/jquery.min.js"></script>
</head>
<body>
    <iframe src="iframe.html"></iframe>
</body>
</html>

iframe.html

<html>
<head>
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="easyui/jquery.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
    $(function(){
         $("-sharpwindow").window({
            width: 200,
            height: 100
        }); 
    });
</script>
</head>
<body>
    <div id="window"></div>
</body>
</html>

effect

iframewindow


index.htmleasyui

I"ve thought about call, apply, _ _ proto__ and so on, and I don"t know what to do.

= temporary solution =

<html>
<head>
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="easyui/jquery.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
    $(function() {

        var script = parent.document.createElement("script");
        script.type = "text/javascript";
        script.src = "easyui/jquery.easyui.min.js";
        parent.document.getElementsByTagName("head")[0].appendChild(script);

        var link1 = parent.document.createElement("link");
        link1.rel = "stylesheet";
        link1.type = "text/css";
        link1.href = "easyui/themes/default/easyui.css";
        parent.document.getElementsByTagName("head")[0].appendChild(link1);
        
        var link2 = parent.document.createElement("link");
        link2.rel = "stylesheet";
        link2.type = "text/css";
        link2.href = "easyui/themes/default/easyui.css";
        parent.document.getElementsByTagName("head")[0].appendChild(link2);
        
    });
    
    function click() {
        var win = parent.document.createElement("div");
        parent.document.body.appendChild(win);
        parent.$(win).window({
            width : 200,
            height : 100
        });
        parent.$("-sharpdiv").window("open");
    }
</script>
</head>
<body>
    <input type="button" onclick="click()" />
</body>
</html>
Mar.07,2021

try, easyui does not support cross-page, but you can dynamically introduce easyui in top and then open window , or you can animate a window in top . Second, the error in your second picture is because jQuery, is not introduced into your top . You can top.$ = $; , but it's useless. The window will be in iframe . Besides, Google Chrome doesn't have the problem with your first picture.

Menu