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 }
  • 相关阅读:
    蜘蛛禁止访问文件
    基于PhalApi的Smarty拓展 (视图层的应用)
    MySQL数据库存表情
    查看PHP版本等相关信息
    读取数据库表信息
    nginx简介
    Redis发布订阅
    Redis持久化
    Redis主从复制
    Redis的Java客户端Jedis
  • 原文地址:https://www.cnblogs.com/aspnetweb/p/3904011.html
Copyright © 2011-2022 走看看