zoukankan      html  css  js  c++  java
  • 提示框

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <title>提示框</title>
     5         <style type="text/css">
     6         #pop{width: 400px;border: 1px solid #666;margin: 100px auto 0px;border-radius: 8px;}
     7         #pop .title{height: 40px;line-height: 40px;overflow: hidden;border-bottom: 1px solid #666;}
     8         #close{float: right;}
     9         #pop .cont{min-height: 100px;}
    10         #pop .btns{height: 50px;text-align: center;}
    11     </style>
    12     <script type="text/javascript">
    13         function popWin(args) {
    14             args.title = args.title || "标题";
    15             args.cont = args.cont || "内容";
    16 
    17             var html = "<div class='title'>" + args.title + "<span id='close'>关闭</span></div>"
    18                         + "<div class='cont'>" + args.cont + "</div>"
    19                         + "<div class='btns'><input id='ok' type='button' value='确定' /><input id='cancel' type='button' value='取消' /></div>";
    20 
    21             var curPop = document.getElementById("pop");
    22 
    23             if (curPop === null) {
    24                 var pop = document.createElement("div");
    25                 pop.setAttribute("id", "pop");
    26                 document.body.appendChild(pop);
    27                 var tmp = document.getElementById("pop")
    28                 tmp.innerHTML = html;
    29             }
    30 
    31             show();
    32 
    33             document.getElementById("close").onclick = function () {
    34                 hide();
    35             }
    36 
    37             document.getElementById("ok").onclick = function () {
    38                 hide();
    39                 args.mok();
    40             }
    41 
    42             document.getElementById("cancel").onclick = function () {
    43                 hide();
    44                 args.mcancel();
    45             }
    46 
    47             function hide() {
    48                 document.getElementById("pop").style.display = "none";
    49             }
    50 
    51             function show() {
    52                 document.getElementById("pop").style.display = "block";
    53             }
    54         }
    55     </script>
    56     <script type="text/javascript">
    57         window.onload = function () {
    58             document.getElementById("test").onclick = function () {
    59 
    60                 new popWin({ "cont": "这里是内容",
    61                     "mok": function () {
    62                         alert("aaaaa");
    63                     },
    64                     "mcancel": function () {
    65                         alert("错误");
    66                     }
    67                 });
    68                 console.log("ccccc");
    69             }
    70         }
    71     </script>
    72 </head>
    73 <body>
    74     <input id="test" type="button" value="弹出框" />
    75 </body>
    76 </html>
  • 相关阅读:
    创建表头固定,表体可滚动的GridView(转)
    正则表达式实现资料验证的技术总结 (转)
    通过样式表实现固定表头和列 (转)
    如何把string解析为int?(转)
    代码设计简单规范 (转)
    取存储过程结果集
    JS对select动态添加options操作[IE&FireFox兼容]
    多UpdatePanel
    ASP.NET页面如何引发PostBack事件 转
    asp.net 页面回传
  • 原文地址:https://www.cnblogs.com/kuikui/p/2543720.html
Copyright © 2011-2022 走看看