Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.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 jQueryUI对话框中的Iframe_Javascript_Jquery - Fatal编程技术网

Javascript jQueryUI对话框中的Iframe

Javascript jQueryUI对话框中的Iframe,javascript,jquery,Javascript,Jquery,我在jquery UI对话框中有一个iframe,将其src设置为doument.ready事件: $(document).ready(function() { $("#iframe").attr("src", whatever); $("#button").click(function() { $("#dialog").dialog(); }); }); <div id="dialog"> <iframe src=""

我在jquery UI对话框中有一个iframe,将其src设置为doument.ready事件:

    $(document).ready(function() {
     $("#iframe").attr("src", whatever);
     $("#button").click(function() { $("#dialog").dialog(); });
    });

    <div id="dialog">
     <iframe src="" id="iframe"></iframe>
    <div>
$(文档).ready(函数(){
$(“iframe”).attr(“src”,随便什么);
$(“#按钮”)。单击(函数(){$(“#对话框”)。对话框();});
});

当我点击打开对话框的按钮时,一切都很顺利,但问题是每次打开对话框时,它都会加载iframe内容。我想停止这种行为,并在document.ready事件时只加载一次内容。我怎么做?

使用另一个iframe,隐藏,然后在对话框打开时,只需将其内容复制到对话框中的iframe中。

问题在于,当您关闭对话框时,JqueryUI会破坏它


这里有一个简单的解决方法:

如何复制内容?
var content=$('#hidden iframe').html()$('#iframe').html(内容)