自定义alert和confirm
var common = {}; common.showAlert = function (msg) { var html = "<div id='dialog_alert' class=\"eject dialog_alert\" style=\"display:block;z-index:9999999999;\">"; html+="<div class=\"web-feedback w400\">"; html+="<div class=\"eject-ly\">"; html+="<div class=\"eject-ly-lef fl\">"; html+="<span class=\"fl\"><img src=\"images/ckwls_03.jpg\"></span>"; html+="<span class=\"fl eject-ckl\">提示</span>"; html+="<span class=\"fl\"><img src=\"images/ckwls_05.jpg\"></span>"; html+="</div>"; html += "<div class=\"fr eject-lyr\" onclick='common.hideAlert()'>"; html+="<img src=\"images/close.jpg\">"; html+="</div>"; html+="</div>"; html+="<div class=\"upload-prompt\">"; html += msg; html+="</div>"; html+="</div>"; html+="<div class=\"hiddenDiv\"> </div>"; html+="</div>"; $("body").append(html); } common.hideAlert = function () { $(".dialog_alert").remove(); } common.showWarn = function (msg) { var html = "<div id='dialog_warn' onclick='common.hideWarn()' class=\"eject dialog_warn\" style=\"display:block;z-index:9999999999;\">"; html += "<div class=\"web-feedback w400\">"; html += "<div class=\"eject-ly\">"; html += "<div class=\"eject-ly-lef fl\">"; html += "<span class=\"fl\"><img src=\"images/ckwls_03.jpg\"></span>"; html += "<span class=\"fl eject-ckl\">提示</span>"; html += "<span class=\"fl\"><img src=\"images/ckwls_05.jpg\"></span>"; html += "</div>"; html += "<div class=\"fr eject-lyr\" onclick='common.hideWarn()'>"; //html += "<img src=\"images/close.jpg\">"; html += "</div>"; html += "</div>"; html += "<div class=\"upload-prompt\">"; html += msg; html += "</div>"; html += "</div>"; html += "<div class=\"hiddenDiv\"> </div>"; html += "</div>"; $("body").append(html); $('#dialog_warn').fadeIn('slow'); } common.hideWarn = function () { $(".dialog_warn").fadeTo("slow", 0.01, function () {//fade $(this).slideUp("slow", function () {//slide up $(this).remove();//then remove from the DOM }); }); } /* *自定义confirm 调用方法common.showConfirm("确定***吗?",function(){alert('确定函数')},function(){alert('不确定函数')}); */ common.showConfirm = function (msg, callback_ok,callback_cancel) { var html = "<div class=\"eject dialog_confirm\" ng-show=\"confirmstate\" style=\"display:block;z-index:9999999999;\">"; html += "<div class=\"web-feedback w280\">"; html += "<div class=\"eject-ly\">"; html += "<div class=\"eject-ly-lef fl\">"; html += "<span class=\"fl\"><img src=\"images/ckwls_03.jpg\"></span>"; html += "<span class=\"fl eject-ckl\">确认</span>"; html += "<span class=\"fl\"><img src=\"images/ckwls_05.jpg\"></span>"; html += "</div>"; html += "<div class=\"fr eject-lyr\">"; html += "<img src=\"images/close.jpg\" onclick=\"common.hideConfirm()\">"; html += "</div>"; html += "</div>"; html += "<div class=\"alert-contet\" style=\"min-height:10px;\">"; html += msg; html += "</div>"; html += "<div class=\"confirm-confirm\">"; html += "<a class=\"fl confirm-con\" id=\"confirm_ok\">确认</a>"; html += "<a class=\"fr confirm-esc\" id=\"confirm_cancel\">取消</a>"; html += "</div>"; html += "</div>"; html += "<div class=\"hiddenDiv\"> </div>"; html += "</div>"; $("body").append(html); $("#confirm_ok").click(function () { if (callback_ok && typeof callback_ok == "function") callback_ok(true); $(".dialog_confirm").remove(); }); $("#confirm_cancel").click(function () { if (callback_cancel && typeof callback_cancel == "function") callback_cancel(true); $(".dialog_confirm").remove(); }); }
posted on 2016-09-27 11:32 tongdengquan 阅读(251) 评论(0) 编辑 收藏 举报