我的代码如下:
function loadPage(url){
$("#wrapper").load(url, function(){
$("#wrapper").find($('a')).each(function(){
$(this).on('click', function(e){
loadPage($(this).attr('href'));
e.preventDefault();
});
});
});
}
function JQueryAlert(message,windowHeight){
if (!windowHeight) var windowHeight = 470;
$("#msgdialog").remove();
$("body").append("<div id='msgdialog'></div>");
thatmsg = $("#msgdialog");
$("#msgdialog").dialog({
resizable: false,
draggable: false,
width: 770,
height: windowHeight,
context: thatmsg,
modal: true,
autoOpen: false,
buttons: {
"Cancel" : function (){
thatmsg.dialog("close");
},
"OK" : function (){
loadPage("combat.php");
}
}
});
$("#msgdialog").html(message);
$("#msgdialog").dialog('open');
}
$(document).ready(function() { JQueryAlert("HELLO!", 120); });
如您所见,这会显示一个弹出警告框,当用户单击“确定”时,它会加载文件combat.php。 Combat.php只是一个准系统的php文件,它回应了一些调试信息,比如“Hello world!”。
现在,我的问题是,点击OK和combat.php加载后,第一个弹出窗口消失,但是另一个弹出窗口出现了。我可以通过调用document.body.remove(“#ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix”)来摆脱它;在我的combat.php中,但这会产生“Hello World!”的不良影响。不再显示。我如何摆脱这种不必要的弹出???
感谢阅读。
答案 0 :(得分:0)
使用:
"OK" : function (){
loadPage("combat.php");
thatmsg.dialog("close");
}