Using an iframe in jquery.simplemodal, the iframe reload when the popup is closed

末鹿安然 提交于 2020-01-04 04:37:11

问题


var pt_popup_options = {};

function pt_popup_iframe(sURL, sOkFunction)
{
    pt_popup_okfunction = sOkFunction;
    $("#pt_msgBox").css('width', '700px');
    $("#pt_msgBox").css('heigth', '500px');
    $("#pt_msgBox > p").html('<iframe style="width: 696px; height: 496px;" src="' + sURL + '"></iframe>');
    $("#pt_msgBox").modal(pt_popup_options);
}

When the popup is closed via a close button or the "x" top right of the popup, the iframe reloads and make a request to the server. It is not supposed to do that. Any idea to prevent that? I'm on Chrome and jQuery 1.4.2.

Thank you!


回答1:


I had the same problem.

Easiest way to fix it is to set the persist option.

$("#pt_msgBox").modal({persist:true});

As of simplemodal-1.3.5

persist: (Boolean:false) Persist the data across modal calls? Only used for existing DOM elements. If true, the data will be maintained across modal calls, if false, the data will be reverted to its original state.




回答2:


Another option if you're using jQueryUI's dialog, I wrote an extension a while ago that handles the various iFrame issues within a dialog...

http://plugins.jquery.com/project/jquery-framedialog




回答3:


Seems to work with:


$("#pt_msgBox > p").html('<iframe style="width: 696px; height: 496px;"></iframe>');
$("#pt_msgBox").modal(pt_popup_options);
$('#pt_msgBox').find('iframe').attr('src', sURL);   


来源:https://stackoverflow.com/questions/2382157/using-an-iframe-in-jquery-simplemodal-the-iframe-reload-when-the-popup-is-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!