学习网考试学习资料

Gzu521.com

javascript实现仿新浪信息提示效果

Javascript教程   点击:次   发布时间:2006-11-2   【字体: 】   来源:Gzu521.com
贵 州 学 习 网
以下是引用片段: 
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">   .@7#`=%O[转 贴 于 我 的 学 习 网 网页设计Javascript教程 HTtp://wwW.gzU521.coM).@7#`=%O
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">  
 <head>  
  <meta name="verify-v1" content="p4t6ffcipvxqmwz2eztyxvzmhlnwd0wlqoq6lbhn5y8=" />  
  <title>政策文件_中国电力工程造价信息网</title>  
  <meta http-equiv="content-type" content="text/html; charset=gb2312" />  
  <meta http-equiv="content-language" content="gb2312" />  
  <meta name="keywords" content="电力工程造价,价格信息,装材,设备,电力工程" />  
  <meta name="description" content="电力工程造价信息" />  
  <style type="text/css">  
      *{  
          margin:0;padding:0;  
      }  
  </style>  
 </head>  
 <body>  
   
 <div class="cecmbody" id="cecmpolicy">  
  <div class="leftclass">  
  <a href=http://homepage.yesky.com>网页陶吧</a>  
  <input type="button" value="点击这里" onclick="salert(’hello’);" />  
  </div>  
  <div class="rightclass">  
  </div>   
 </div>  
    <script type="text/javascript" language="javascript">  
//author:daviv  
//blog:http://blog.163.com/jxdawei  
//date:2006-10-27  
//email:jxdawei@gmail.com  
   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=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 ="25px";  
            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;   *FB;]j_C[本文 来源 于我 的学习 网网页设计Javascript教程 WWW.GZU521.COM )*FB;]j_C
     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);  
            }  
  </script>  
 </body>  
</html> 

责任编辑:gzu521

网页设计分类
HTML教程
CSS教程
Javascript教程
Dreamweaver教程
FrontPages教程
FireWorks教程
Flash教程
PhotoShop教程
建站知识
分类推荐信息
更多...
大类最新文章
更多...