2012-05-27 68 views
0

我在jQuery用戶界面對話框中的iframe,在doument.ready事件設置它的src:的iFrame在jQuery UI的對話框

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

    <div id="dialog"> 
    <iframe src="" id="iframe"></iframe> 
    <div> 

一切都很好,當我click over the button dialog openthe problem是它loads iframe content everytime when dialog open。 I want to stop此行爲和load the contents only once at document.ready event。我該如何做?

回答

0

使用另一個iframe,隱藏,然後在對話框打開,只需將其內容複製到對話框中的iframe。

+0

我們如何複製內容? – gaurav

+0

'var content = $('#hidden-iframe')。html(); $('#iframe')。html(content);' – slash197

+0

這不起作用 – gaurav