【www.gdgbn.com--js教程】

function salert(str){
   var msgw,msgh,bordercolor;
   msgw=400;//提示窗口的宽度
   msgh=100;//提示窗口的高度
   titleheight=25 //提示窗口标题高度
   bordercolor="#336699";//提示窗口的边框颜色
   titlecolor="#99ccff";//提示窗口的标题颜色
   
   var swidth,sheight;
   swidth=document.body.offsetwidth;
   sheight=document.body.offsetheight;
   if (sheight    {
    sheight=screen.height;
   }

   var bgobj=document.createelement("div");
   bgobj.setattribute("id","bgdiv");
   bgobj.style.position="absolute";
   bgobj.style.top="0";
   bgobj.style.background="#777";
   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 = (msgh-titleheight) + "px";
            msgobj.style.zindex = "10001";
  
     var title=document.createelement("h4");
     title.setattribute("id","msgtitle");
     title.setattribute("align","right");
     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";
     title.style.cursor="pointer";
     title.innerhtml="关闭";
     title.onclick=function(){
          document.body.removechild(bgobj);
                document.getelementbyid("msgdiv").removechild(title);
                document.body.removechild(msgobj);
                }
     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);
            }

//调用方法

功能:弹出提示
   方法:调用salert("您要弹出的信息");

本文来源:http://www.gdgbn.com/wangyezhizuo/27761/