我的代码如下:
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); });
如您所见,这会显示一个弹出警告框,并且在用户单击“确定”时,它会加载文件战斗.php。Combat.php 只是一个简单的 php 文件,它会回显一些调试消息,例如“Hello world!”。
现在,我的问题是,单击“确定”并加载战斗.php 后,第一个弹出窗口消失了,但又出现了另一个弹出窗口。我可以通过调用 document.body.remove("#ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"); 来摆脱它。在我的战斗.php 中,但这会产生“Hello World!”的不良影响。不再显示。我如何摆脱这个不需要的弹出窗口???
谢谢阅读。