:
Call Mode:
Confirm (' OK delete? ', function (boo) {
if (boo) {
User clicks OK
}else{
User Click Cancel
}
})
Css:
. Btn{display:inline-block;margin-bottom:0;font-weight:normal;text-align:center;vertical-align:top;cursor: Pointer;background-image:none;
border:1px solid transparent;padding:5px 6px;line-height:16px;color: #fff; Background-color: #83b266; White-space:nowrap;font-size:14px;border-radius:4px;-webkit-user-select:none;
-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;margin-right:6px;}
. Btn.big{padding:8px 30px;}
. Btn.read{background-color: #ff4e00;}
. Confirm{position:fixed;width:100%;height:100%;background-color:rgba (0,0,0,0.5); top:0;left:0;z-index:99;}
. Close{background:url (Images/close.png) no-repeat;background-size:100% 100%;width:16px;height:16px;right:20px; top:10px; Position:absolute;}
. Confirm. Confirmbox{position:absolute;top: -500px;background-color: #fff; Border-radius:10px;left:50%;margin-left: -175px;}
. Confirm. Confirmtitl{background-color: #83b266; text-align:center; color: #fff;p adding:12px 20px;border-top-left-radius:10px ; border-top-right-radius:10px;}
. Confirm. Confirmcont{background-color: #fff; overflow:hidden;width:280px;padding:10px 30px;text-align:center;}
. Confirm. confirmquset{display:inline-block;padding:20px 0 20px 60px;background:url (images/shouoye_26.png) no-repeat; Background-position:left center;line-height:24px;}
. Confirm. confirmbtn{text-align:center;padding:10px 30px;margin-bottom:10px;}
. Confirm. Confirmbtn. read{margin-left:30px;}
Js:
Dependent JQ Library
function Confirm (quest,callback) {
var Confirm = document.createelement (' div ');
Confirm.classname = ' Confirm ';
$ (Confirm). Append (
' <div class= "Confirmbox" ><div class= "CONFIRMTITL" > System hint <span class= "close" ></span></div > '
+ ' <div class= "Confirmcont" ><div class= "Confirmquset" > ' +quest+ ' </div></div><div class= " Confirmbtn ">"
+ ' <span class= "Btn big" > Confirm </span><span class= "Btn Big Read" > Cancel </span></div></div > '
);
$ (' body '). Append (Confirm);
$ ('. Confirmbox '). Animate ({' Top ': parseint ($ (window). Height ()/3)-parseint ($ ('. Confirmbox '). Height ()/2)},300);
$ (Confirm). Click (function (e) {
if (E.target = = $ ('. Confirm. Close ') [0]) {
Remove ()
Callback?callback (false): ';
}else if (E.target = = $ ('. Confirm. Btn ') [0]) {
Remove ()
Callback?callback (true): ';
}else if (E.target = = $ ('. Confirm. Btn ') [1]) {
Remove ()
Callback?callback (false): ';
}else{
Return
}
})
function Remove () {
$ ('. Confirmbox '). Animate ({' Top ': ' -500px '},300,function () {
$ (Confirm). Remove ()
})
}
};
Confirm method of Imitation window object