将cAlert.show(内容)更改为cAlert.show(内容,成功).
将cAlert.ok()更改为cAlert.ok(‘success’).
将this.ok = function()更改为this.ok = function(成功),最后添加success();到ok()函数的末尾.
单击cAlert中的按钮时,这将调用成功.
您现在需要调用cAlert.show(“text”,function(){javascript:history.go(-1);}),而不是调用cAlert.show(“text”).
所以你的代码现在应该是:
function cAlert()
{
var bOn;
this.show = function (content,success)
{
bOn = true;
document.write('
![](Images/Vectors/1429744831_678136-shield-warning-64.png)
$("#cAlertContentBox").html(content);
$("#cAlertBox").show();
$("#turnOffLight").fadeIn("fast");
var div = document.getElementById('cAlertBox').offsetWidth;
var res = -Math.abs(div / 2);
document.getElementById('cAlertBox').style.marginTop = res + "px";
};
this.ok = function (success)
{
$("#cAlertBox").hide();
$("#turnOffLight").fadeOut("medium");
bOn = false;
success();
};
}
和:
var cAlert = new cAlert();
cAlert.show("text",function() { javascript:history.go(-1); } );