Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何关闭脚本未打开的窗口/弹出窗口_Javascript_Jquery_Html_Css_Smartgwt - Fatal编程技术网

Javascript 如何关闭脚本未打开的窗口/弹出窗口

Javascript 如何关闭脚本未打开的窗口/弹出窗口,javascript,jquery,html,css,smartgwt,Javascript,Jquery,Html,Css,Smartgwt,我的情况是这样的。用于UI端的技术是SmartGwt。 在我的应用程序中,单击一个按钮,打开一个弹出窗口,然后从跨域url加载html内容。 我在弹出窗口中的html代码中没有弹出窗口引用 我有关闭按钮内的html弹出窗口单击关闭按钮的,窗口应关闭 目前它还没有发生。我尝试了window.close()方法以及window.postmessage实现。什么都没用 当脚本未打开窗口时,如何关闭弹出窗口 有什么想法吗?在父页面中使用此代码 /*For closing the popups from

我的情况是这样的。用于UI端的技术是SmartGwt。 在我的应用程序中,单击一个按钮,打开一个弹出窗口,然后从跨域url加载html内容。 我在弹出窗口中的html代码中没有弹出窗口引用

我有关闭按钮内的html弹出窗口<代码>单击关闭按钮的,窗口应关闭

目前它还没有发生。我尝试了
window.close()
方法以及window.postmessage实现。什么都没用

当脚本未打开窗口时,如何关闭弹出窗口


有什么想法吗?

在父页面中使用此代码

 /*For closing the popups from inside close button*/
    closeDialog = function () {
        $("#dialog").dialog("close");
    }
在子页面中使用此代码

   jQuery(function () {

        jQuery("#btnClose").click(function () {
            parent.closePopup();
        });
    });

我对SmartGwt不是很熟悉,只要您不提供代码或html示例,我的建议就会更一般

因此,您的代码应该如下所示:

    ...
    var popUp=window.open(/*arguments*/); // open the window
    ...
    popUp.close(); // close the window

或者你可以用一些
div
来包装一个
iframe
来创建一个伪弹出窗口(并通过操纵
iframe
的src和包装
div
的可见性来“打开”/“关闭”它),而不是打开/关闭实际的窗口。

你是否尝试过绑定
window.open('''u self').close()到”
onclick
?@ebilgin Thatscorrect@sander我试过了。。在这里,我通过我的应用程序打开弹出窗口。弹出窗口中的内容来自其他域,我无法控制。当我尝试使用Windows访问弹出窗口时。家长,我收到这个异常“阻止了一个具有原点的帧……”