alt和title的提示层

 1 tPopWait=50;
2 tPopShow=2000; //提示层的渐渐消失时间
3 showPopStep=90;
4 popOpacity=90;//提示层的透明度
5
6 sPop=null;
7 curShow=null;
8 tFadeOut=null;
9 tFadeIn=null;
10 tFadeWaiting=null;
11
12 document.write("<style type='text/css'id='defaultPopStyle'> .cPopText { background-color: #FFFFCC;border: 1px solid #999999;font-size: 9pt;margin: 3px;padding: 3px; z-index:9999;filter: Alpha(Opacity=0)}</style>");
13 document.write("<div id='dypopLayer' style='position:absolute;z-index:9999;' class='cPopText'></div>");
14
15 function showPopupText(){
16 var o=event.srcElement;
17 MouseX=event.x;
18 MouseY=event.y;
19 if(o.alt!=null && o.alt!=""){ o.dypop=o.alt;o.alt=""};
20 if(o.title!=null && o.title!=""){ o.dypop=o.title;o.title=""};
21 if(o.dypop!=sPop){
22 sPop=o.dypop;
23 clearTimeout(curShow);
24 clearTimeout(tFadeOut);
25 clearTimeout(tFadeIn);
26 clearTimeout(tFadeWaiting);
27 if(sPop==null || sPop==""){
28 dypopLayer.innerHTML="";
29 dypopLayer.style.filter="Alpha()";
30 dypopLayer.filters.Alpha.opacity=0;
31 }else{
32 if(o.dyclass!=null) popStyle=o.dyclass
33 else popStyle="cPopText";
34 curShow=setTimeout("showIt()",tPopWait);
35 }
36 }
37 }
38
39 function showIt(){
40 dypopLayer.className=popStyle;
41 dypopLayer.innerHTML=sPop;
42 popWidth=dypopLayer.clientWidth;
43 popHeight=dypopLayer.clientHeight;
44 if(MouseX+2+popWidth>document.body.clientWidth) popLeftAdjust=1
45 else popLeftAdjust=0;
46 if(MouseY+2+popHeight>document.body.clientHeight) popTopAdjust=1
47 else popTopAdjust=0;
48 dypopLayer.style.left=MouseX+6+document.body.scrollLeft+popLeftAdjust;
49 dypopLayer.style.top=MouseY+6+document.body.scrollTop+popTopAdjust;
50 dypopLayer.style.filter="Alpha(Opacity=0)";
51 fadeOut();
52 }
53
54 function fadeOut(){
55 if(dypopLayer.filters.Alpha.opacity<popOpacity){
56 dypopLayer.filters.Alpha.opacity+=showPopStep;
57 tFadeOut=setTimeout("fadeOut()",1);
58 }else{
59 dypopLayer.filters.Alpha.opacity=popOpacity;
60 tFadeWaiting=setTimeout("fadeIn()",tPopShow);
61 }
62 }
63
64 function fadeIn(){
65 if(dypopLayer.filters.Alpha.opacity>0){
66 dypopLayer.filters.Alpha.opacity-=1;
67 tFadeIn=setTimeout("fadeIn()",1);
68 }
69 }
70 document.onmouseover=showPopupText;

 

posted @ 2012-01-17 16:13  祥辉  阅读(274)  评论(0编辑  收藏  举报