This article for you to introduce the use of jquery simple implementation of the Package dialog box, the implementation of the Code as follows, interested friends can refer to ha, I hope to help you
copy code code as follows:
var _alert_iconcss = "Tipmsg_icoinfo";
var _confirm_iconcss = "Tipmsg_icoconfirm";
var _error_iconcss = "Tipmsg_icoerror";
var _warning_iconcss = "Tipmsg_icowarning";
function Dialoginit (type, msg) {
var iconcss = "";
switch (type) {
case "Confirm": Iconcss = _confirm_iconcss; Break
case "Error": Iconcss = _error_iconcss; Break
case "Warning": Iconcss = _warning_iconcss; Break
default:iconcss = _alert_iconcss; Break
}
var htmlstr = "<div id= '" + type + "div ' style= ' display:none; ' ><p><span class= ' "+ iconcss +" ' style= ' float:left; margin:0 7px 50px 0;width:35px;height:35px; ' ></span> "+ msg + </p></div>";
return htmlstr;
}
function Alert (msg, okcallback) {
var title = "Hint";
var type = "Alert";
var html = dialoginit (type, msg);
var div = $ (' body '). Find ("#" +type+ "div");
Div.remove ();
$ (' body '). Append ($ (HTML));
var buttons = {ok: function () {
if (okcallback) Okcallback ();
$ (this). dialog ("Close");
}
};
$ ("#" +type+ "Div"). Dialog ({
Modal:true,
Title:title,
buttons:buttons
});
}
function Confirm (msg, Okcallback, cancelcallback) {
var title = "Confirmation";
var type = "Confirm";
var html = dialoginit (type, msg);
var div = $ (' body '). Find ("#" +type+ "div");
Div.remove ();
$ (' body '). Append ($ (HTML));
var buttons = {ok: function () {
if (okcallback) Okcallback ();
$ (this). dialog ("Close");
},
"Cancel": function () {
if (cancelcallback) Cancelcallback ();
$ (this). dialog ("Close");
}
};
$ ("#" +type+ "Div"). Dialog ({
Modal:true,
Title:title,
buttons:buttons
});
}
function Error (msg, okcallback) {
var title = "Error";
var type = "Error";
var html = dialoginit (type, msg);
var div = $ (' body '). Find ("#" +type+ "div");
Div.remove ();
$ (' body '). Append ($ (HTML));
var buttons = {ok: function () {
if (okcallback) Okcallback ();
$ (this). dialog ("Close");
}
};
$ ("#" +type+ "Div"). Dialog ({
Modal:true,
Title:title,
buttons:buttons
});
}
function Warning (msg, okcallback) {
var title = "Warning";
var type = "Warning";
var html = dialoginit (type, msg);
var div = $ (' body '). Find ("#" +type+ "div");
Div.remove ();
$ (' body '). Append ($ (HTML));
var buttons = {ok: function () {
if (okcallback) Okcallback ();
$ (This). dialog ("Close");
}
};
$ ("#" +type+ "Div"). Dialog ({
Modal:true,
Title:title,
buttons:buttons
});
}