zoukankan      html  css  js  c++  java
  • 友好地弹出对话框

     1 function showMessage(msg, bgColor, borderColor) {
     2     if ($("#showDiv").length <= 0) {
     3         var div = window.document.createElement("div");
     4         div.innerHTML = msg;
     5         div.id = "showDiv";
     6         div.style.color = "black";
     7         div.style.width = "400px";
     8         div.style.height = "auto";
     9         div.style.padding = "15px";
    10         div.style.lineHeight = "22px";
    11         div.style.overflow = "auto";
    12         div.style.border = borderColor;
    13         div.style.display = "none";
    14         div.style.position = "fixed";
    15         div.style.zIndex = 40;
    16         div.style.fontFamily = "Microsoft YaHei";
    17         div.style.fontSize = "15px";
    18 
    19         div.style.background = bgColor;
    20         var p = window.document.createElement("p");
    21         p.style.marginBottom = "0px";
    22         p.style.textAlign = "right";
    23 
    24         $(p).html("<a id='closeA' href='javascript:void(0)' style='text-decoration:none'>关闭</a>");
    25         div.appendChild(p);
    26         window.document.body.appendChild(div);
    27 
    28         div.style.left = (window.document.documentElement.clientWidth / 2 - parseInt(div.style.width, 10) / 2) + "px";
    29         div.style.top = window.document.documentElement.clientHeight / 2 - $(div).height() / 2 + "px";
    30         animationDiv(div);
    31 
    32         //这里要放在元素被body加载了后再绑定事件,不然放在加载之前执行不了事件
    33         $("#closeA").click(function () {
    34             $("#showDiv").remove();
    35         });
    36 
    37         $(window).resize(function () {
    38             div.style.left = (window.document.documentElement.clientWidth / 2 - parseInt(div.style.width, 10) / 2) + "px";
    39             div.style.top = window.document.documentElement.clientHeight / 2 - $(div).height() / 2 + "px";
    40         });
    41 
    42     } else {
    43         //$("#showDiv").html(msg + "<p style='text-align:right'><a id='closeA' href='javascript:void(0)' style='text-decoration:none'>关闭</a></p>");
    44         //这里要放在元素被body加载了后再绑定事件,不然放在加载之前执行不了事件
    45         $("#closeA").click(function () {
    46             $("#showDiv").remove();
    47         });
    48     }
    49 }
  • 相关阅读:
    分治法(求最大子序列和)
    分治法(二分查找)
    自定义选择动画提示
    将图片转为二进制字符串
    根据尺寸压缩图片
    在ios7系统下,scrollView下移20像素
    UIActionSheet警告,提示调用showFromTabBar方法
    使用Xcode5开发时的icon取消高光效果
    duplicate symbol _OBJC_METACLASS_$ 报错记录
    self.view添加UIView时添加动画
  • 原文地址:https://www.cnblogs.com/aspnetweb/p/3904011.html
Copyright © 2011-2022 走看看