Copy codeThe Code is 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 = "prompt ";
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 = "OK ";
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
});
}