Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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 使用外部html从iFrame关闭jquery对话框_Javascript_Jquery_Html_Jquery Ui_Iframe - Fatal编程技术网

Javascript 使用外部html从iFrame关闭jquery对话框

Javascript 使用外部html从iFrame关闭jquery对话框,javascript,jquery,html,jquery-ui,iframe,Javascript,Jquery,Html,Jquery Ui,Iframe,我试图从一个内部带有外部html的iframe关闭一个jQueryUI对话框 我的代码如下所示: 单击按钮时,在我的主html中创建对话框的JS代码: function createDialog() { return $("<div id='personal-popup' class='dialog' title='Copia de archivos'></div>") .html('<iframe style="border: 0p

我试图从一个内部带有外部html的iframe关闭一个jQueryUI对话框

我的代码如下所示:

单击按钮时,在我的主html中创建对话框的JS代码:

function createDialog() {
        return $("<div id='personal-popup' class='dialog' title='Copia de archivos'></div>")
        .html('<iframe style="border: 0px; " src="copy.html" width="100%" height="100%"></iframe>')
        .dialog({
            resizable: true,
            height: 447.59999990463257,
            width: 993.5999999046326,
            modal: true
        });
    }
我遵循了这个问题的答案:,但它对我不起作用

---编辑---

将从iFrame调用的JS函数,在mane html(index.html)中分配

来自iframe的JS调用(copy.html)


从iframe内部,您可以访问
window.parent

这意味着在主框架中,您可以:

window.closeDialog=function(){//Do stuff}

Anf然后在您的iframe中:


window.parent.closeDialog()

我已经按照你说的做了,但仍然不适合我。我添加了以下js功能:函数closeDialog(){document.getElementById(“个人弹出”).dialog(“关闭”);}尝试添加
console.log(“Im工作!!”)
进入函数,查看调用是否正确:)我在控制台中看不到任何内容,但ajax调用完成了,因为我可以看到复制到我的目录中的文件。。。有点奇怪…这意味着函数没有被调用。尝试将函数放在iframe中的
$(document).ready(function(){//function here})
调用ajax时,我可以看到$.mobile.loading是如何隐藏的,没有调用的是js函数,它是主html。无论如何,如果我把函数放在我的第二个html(copy.html)中,我就不能访问对话框div,是吗?
function copiarArchivos() {


$.mobile.loading('show',{
  text: "Copiando",
  textVisible: true,
  theme: "a",
  html: ""
});

var result = [];

var allOptions = $("#select-custom-19");

$("#select-custom-19 option:selected").each(function () {

var $this = $(this);
var selText = $this.text();
$this.prop("selected", false);
result.push(selText);
});

allOptions.selectmenu('refresh', true);

$.ajax ({
  url: "php/copia.php",
  type: "post",
  data: {"params": result},
  success: function(response) {
        $.mobile.loading('hide');
        //I want to close the dialog here when the ajax function success
        $(window.parent.document).find("#personal-popup").dialog('close');
    }

}); 
}
function closeDialog(){
    console.log("Im working!!");
    document.getElementById("personal-popup").dialog("close");
    }
$.ajax ({
  url: "php/copia.php",
  type: "post",
  data: {"params": result},
  success: function(response) {
        $.mobile.loading('hide');
        window.parent.closeDialog();
    }

});