开发者

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

开发者 https://www.devze.com 2022-12-22 02:59 出处:网络
var pt_popup_options = {}; function pt_popup_iframe(sURL, sOkFunction) { pt_popup_okfunction = sOkFunction;
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 se开发者_开发技巧rver. It is not supposed to do that. Any idea to prevent that? I'm on Chrome and jQuery 1.4.2.

Thank you!


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.


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


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);   
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号