Copy Code code as follows:
<script type= "Text/javascript" src= "Js/jquery-1.7.1.min.js" ></script>
<!--[if IE 6]>
<script type= "Text/javascript" src= "Js/iepngfix_tilebg.js" ></script>
<! [endif]-->
<script type= "Text/javascript" >
function position (elem,l,t) {
var isIE6 =!-[1,] &&!window. XMLHttpRequest;
if (isIE6) {
var style = Elem.style,
Dom = ' (document.documentelement) ',
left = L-document.documentelement.scrollleft,
top = T-document.documentelement.scrolltop;
style.position = ' absolute ';
Style.removeexpression (' left ');
Style.removeexpression (' top ');
Style.setexpression (' left ', ' eval (' + Dom + '. ScrollLeft + ' + Left + ') + "px");
Style.setexpression (' top ', ' eval (' + Dom + '. ScrollTop + ' + top + ') + "px");
}else{
elem.style.position = ' fixed ';
}
}
function Scscms_alert (Msg,sign,ok,can) {
Whether the Var c_=false;//has closed the window to resolve automatic shutdown and manual shutdown conflicts
sign=sign| | "";
var s= "<div id= ' mask_layer ' ></div><div id= ' scs_alert ' ><div id= ' alert_top ' ></div>< Div id= ' alert_bg ' ><table width= ' align= ' center ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 1 ' ><tr> ';
if (sign!= "") s+= "<td width= ' ><div id= ' inco_ ' +sign+ '" ' ></div></td> ";
s+= "<td id= ' alert_txt ' >" +msg+ "</td></tr></table>";
if (sign== "confirm") {
s+= "<a href= ' javascript:void (0) ' id= ' CONFIRM_OK ' > Identified </a><a href= ' javascript:void (0) ' id= ' confirm_ Cancel ' > Cancel </a> ';
}else{
s+= "<a href= ' javascript:void (0) ' id= ' Alert_ok ' > OK </a>"
}
s+= "</div><div id= ' alert_foot ' ></div></div>";
$ ("Body"). Append (s);
$ ("#scs_alert"). CSS ("Margin-top",-($ ("#scs_alert"). Height ()/2) + "px"); Align it vertically
$ ("#scs_alert"). focus (); Gets the focus in case the function cannot be triggered after carriage return
Position (document.getElementById (' Mask_layer '), 0,0);
Position (document.getElementById (' Scs_alert '), $ (window). Width ()/2,$ (window). Height ()/2);
if (typeof can = = "number") {
Timed shutdown prompt
settimeout (function () {
Close_info ();
},can*1000);
}
function Close_info () {
Close the Prompt window
if (!C_) {
$ ("#mask_layer"). Fadeout ("Fast", function () {
$ ("#scs_alert"). Remove ();
$ (this). Remove ();
});
C_=true;
}
}
$ ("#alert_ok"). Click (function () {
Close_info ();
if (typeof (OK) = = "function") ok ();
});
$ ("#confirm_ok"). Click (function () {
Close_info ();
if (typeof (OK) = = "function") ok ();
});
$ ("#confirm_cancel"). Click (function () {
Close_info ();
if (typeof (CAN) = = "function") can ();
});
function Modal_key (e) {
E = e| | Event
Close_info ();
var code = e.which| | Event.keycode;
if (code = = | | code = =) {if (typeof (OK) = = "function") Ok ()}
if (code = N) {if (typeof (CAN) = = "function") Can ()}
}
Bind carriage return with ESC key
if (document.attachevent)
Document.attachevent ("onkeydown", Modal_key);
Else
Document.addeventlistener ("KeyDown", Modal_key, True);
}
==================================== The following is the test function =======================================//
function Test1 () {
Scscms_alert ("Default hint Information");
}
function Test2 () {
Scscms_alert ("Success Message", "OK");
}
function Test3 () {
Scscms_alert ("callback function after success prompt", "OK", function () {alert ("Callback succeeded!") ")});
}
function Test4 () {
Scscms_alert ("Failure message", "error");
}
function Test5 () {
Scscms_alert ("Failure message", "Error", function () {alert ("Oh! No! ")});
}
function Test6 () {
Scscms_alert ("warning message", "warn");
}
function Test7 () {
Scscms_alert ("warning message", "Warn", function () {alert ("Oh! Warning! ")});
}
function Test8 () {
Scscms_alert ("Do you like this informational hint?") "," Confirm ", function () {
Scscms_alert ("You chose to like, thank you!") "," OK ");
},function () {
Scscms_alert ("You chose not to like, Khan!") "," error ");
});
}
function Test9 () {
Scscms_alert ("This information automatically closes after 3 seconds", "OK", "" ", 3);
}
function test10 () {
Scscms_alert ("Ask the information to close the prompt information, 3 seconds after automatic shutdown, no cancellation callback function." It is not recommended to use. "," Confirm ", function () {alert (" OK callback! "). ")},3);
}
</script>