zoukankan      html  css  js  c++  java
  • 自定义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();
        });
    }

  • 相关阅读:
    window 窗口对象http://www.diybl.com/course/1_web/javascript/jsjs/2007104/76401.html
    Web开发中的Drag&Drop完全手册http://www.cnblogs.com/birdshome/archive/2006/07/22/457369.aspx
    [转载]window 的 setTimeout() 與 clearTimeout() 方法
    javascript this详解(转) http://www.cnblogs.com/felix2007/archive/2007/03/21/682670.html
    关闭浏览器弹出对话框事件onbeforeunload http://www.blogjava.net/jennyli/articles/82351.html
    页面跳转http://www.9ba.cn/post/235.html
    POJ 3667 Hotel
    hdu 2511 汉诺塔 X
    UESTC Another LCIS
    Hdu 1576 A/B
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090467.html
Copyright © 2011-2022 走看看