zoukankan      html  css  js  c++  java
  • javascript 创建自己的alert

    javascript代码   图片为mid-nei-bg_02.gif 

         function openAlert(str)
             {                     
                 str = "常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义";
                 var imgUrl = "images/mid-nei-bg_02.gif";
                 var divAlert = document.createElement("div");    
                 divAlert.id = "openAlert";       
                 divAlert.style.position="absolute";                      
                 divAlert.style.width="280px";
                 divAlert.style.border="1px #CCCCFF solid";
                 divAlert.style.top="200px";
                 divAlert.style.left="-140px";
                 divAlert.style.marginLeft="50%";
                 divAlert.style.zIndex = "1009";
                 divAlert.style.backgroundColor = "White";
                             
                 divAlert.innerHTML = "<div style=\"font-size:smaller;100%;height:26px;line-height:26px;background:url("+imgUrl+");\">&nbsp;&nbsp;系统提示框</div>";
                 divAlert.innerHTML = divAlert.innerHTML + "<div style=\"40px;float:left;background-color:White;\"><img alt='' src='images/alert.png' border='0'/></div>";
                 divAlert.innerHTML = divAlert.innerHTML + "<div style=\"font-size:smaller;240px;text-align:left;float:left;margin-bottom:10px;background-color:white;\"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+str+"</div>";            
                 divAlert.innerHTML = divAlert.innerHTML + "<div style=\"100%;text-align:center;margin-bottom:5px;background-color:white;\"><input type='button' value='确定' style=\"background:url("+imgUrl+");border:1px #ccccff solid;40px;height:26px;\" onclick=\"alertOk()\"/></div>";
                             
                 createShade();
                 document.body.appendChild(divAlert);
                 return false;
             }

    function createShade()
             {
                 var zzDiv = document.createElement("div");
                 zzDiv.id = "zzDiv";
                 zzDiv.style.filter='alpha(opacity=10)';
                 zzDiv.style.backgroundColor = "gray";   
                 zzDiv.style.position="absolute";        
                 zzDiv.style.left="0px";
                 zzDiv.style.top = "0px";
                 zzDiv.style.width="100%";
                 zzDiv.style.height="100%";
                 zzDiv.style.zIndex = "1008";
                 zzDiv.style.backgroundColor = "#F3F3F3";
                 zzDiv.innerHTML = "&nbsp;";
                 document.body.appendChild(zzDiv);
             }
             function alertOk()
             {
                removeOpenAlert();
             }
             function removeOpenAlert()
             {
                window.document.body.removeChild(document.getElementById("openAlert"));
                window.document.body.removeChild(document.getElementById("zzDiv"));           
             }

  • 相关阅读:
    mysql小数和类型转换函数
    concat()用法
    sql修改表名字段名
    having函数,case when与order by
    volatile实现原理与应用
    synchronized的实现原理与应用
    java8策略模式
    centos7快速升级gcc
    一个用户从发起请求到接收到响应,中间经过哪些服务,每个服务做什么事情
    Java注解
  • 原文地址:https://www.cnblogs.com/ajun/p/2185360.html
Copyright © 2011-2022 走看看