zoukankan      html  css  js  c++  java
  • JAVASCRIPT 弹出层

    tag:Javascript 弹出窗口 弹出层 模式对话框 

    function sAlert(str,time){
       var msgw,msgh,bordercolor;
       msgw=400;//Width
       msgh=100;//Height
       titleheight=25 //title Height
       bordercolor="#336699";//boder color
       titlecolor="#99CCFF";//title color
       var sWidth,sHeight;
       sWidth=document.body.offsetWidth;
       sHeight=screen.height;
       var bgObj=document.createElement("div");
       bgObj.setAttribute('id','bgDiv');
       bgObj.style.position="absolute";
       bgObj.style.top="0";
       bgObj.style.background="#000";
       bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
       bgObj.style.opacity="0.6";
       bgObj.style.left="0";
       bgObj.style.width=sWidth + "px";
       bgObj.style.height=sHeight + "px";
       bgObj.style.zIndex = "10000";
       document.body.appendChild(bgObj);
       var msgObj=document.createElement("div")
       msgObj.setAttribute("id","msgDiv");
       msgObj.setAttribute("align","center");
       msgObj.style.background="white";
       msgObj.style.border="1px solid " + bordercolor;
       msgObj.style.position = "absolute";
       msgObj.style.left = "50%";
       msgObj.style.top = "50%";
       msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
       msgObj.style.marginLeft = "-225px" ;
       msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
       msgObj.style.width = msgw + "px";
       msgObj.style.height =msgh + "px";
       msgObj.style.textAlign = "center";
       msgObj.style.lineHeight ="25px";
       msgObj.style.zIndex = "10001";
       var title=document.createElement("h4");
       title.setAttribute("id","msgTitle");
       title.setAttribute("align","center");
       title.style.margin="0";
       title.style.padding="3px";
       title.style.background=bordercolor;
       title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
       title.style.opacity="0.75";
       title.style.border="1px solid " + bordercolor;
       title.style.height="18px";
       title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
       title.style.color="white";
     
       var waitMsg="请等待... ";
      
       title.innerHTML=waitMsg;
       var sec=time;
       var clearAlertFun=function(){
                document.body.removeChild(bgObj);
                document.getElementById("msgDiv").removeChild(title);
                document.body.removeChild(msgObj);
              }
       timerID=window.setInterval(function(){
       try{
       if(sec<0){
        title.onclick=clearAlertFun;
         title.style.cursor="pointer";
              window.clearInterval(timerID);
              document.getElementById("msgTitle").innerHTML='操作超时,请点击关闭'
       }else
       document.getElementById("msgTitle").innerHTML=waitMsg+sec--+'s';
       }catch(e)
       {
        window.clearInterval(timerID);
       }
      ;},1000);
      
       document.body.appendChild(msgObj);
       document.getElementById("msgDiv").appendChild(title);
       var txt=document.createElement("p");
       txt.style.margin="1em 0"
       txt.setAttribute("id","msgTxt");
       txt.innerHTML=str;
       document.getElementById("msgDiv").appendChild(txt);
    }
    function   cAlert()
    {
      document.body.removeChild(document.getElementById("bgDiv"));
            document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
            document.body.removeChild(document.getElementById("msgDiv"));
    }

    修改自:http://www.cnblogs.com/blodfox777/archive/2008/05/26/1207337.html

  • 相关阅读:
    JWT在flask中的demo
    14.Android开发笔记:碎片(Fragment)
    13.Android开发笔记:界面开发最佳实践
    12.Android开发笔记:RecyclerView
    11.Android开发笔记:ListView
    10.Android开发笔记:布局控件(五) 自定义控件
    9.Android开发笔记:布局控件(四) 百分比布局
    8.Android开发笔记:布局控件(三)FrameLayout 帧布局
    7.Android开发笔记:布局控件(二)RelativeLayout 相对布局
    6.Android开发笔记:布局控件(一)LinearLayout 线性布局
  • 原文地址:https://www.cnblogs.com/yangyh/p/1777685.html
Copyright © 2011-2022 走看看