用DW中ToolTip代码改进的提示框

2006-01-12 23:17:48

这个我早就改好了一直没有放上来.现在发给大家用用 注意这几个变量它们影响到提示框的效果 var rT=true;//允许图像过渡 var bT=true;//允许图像淡入淡出 var tw=150;//提示框宽度 var endaction=false;//结束动画 css控制动画效果 <style type="text/css"> <!-- .trans_msg { filter:alpha(opacity=100,enabled=1) revealTrans(duration=.2,transition=1) blendtrans(duration=.2); } --> </style> 只要把里面的'revealTrans(duration=.2,transition=1)'滤镜的transition值改变可以换动画过渡效果了. 不说这么多了地球人都知道 revealTrans 和 blendtrans了吧 [code]<head> <title>图像效果演示</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <script> /* 舜子制作 Made by PuterJam */ //--初始化变量-- var rT=true;//允许图像过渡 var bT=true;//允许图像淡入淡出 var tw=150;//提示框宽度 var endaction=false;//结束动画 var ns4 = document.layers; var ns6 = document.getElementById && !document.all; var ie4 = document.all; offsetX = 0; offsetY = 20; var toolTipSTYLE=""; function initToolTips() { if(ns4||ns6||ie4) { if(ns4) toolTipSTYLE = document.toolTipLayer; else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style; else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style; if(ns4) document.captureEvents(Event.MOUSEMOVE); else { toolTipSTYLE.visibility = "visible"; toolTipSTYLE.display = "none"; } document.onmousemove = moveToMouseLoc; } } function toolTip(msg, fg, bg) { if(toolTip.arguments.length < 1) // hide { if(ns4) { toolTipSTYLE.visibility = "hidden"; } else { //--图象过渡,淡出处理-- if (!endaction) {toolTipSTYLE.display = "none";} if (rT) document.all("msg1").filters[1].Apply(); if (bT) document.all("msg1").filters[2].Apply(); document.all("msg1").filters[0].opacity=0; if (rT) document.all("msg1").filters[1].Play(); if (bT) document.all("msg1").filters[2].Play(); if (rT){ if (document.all("msg1").filters[1].status==1 || document.all("msg1").filters[1].status==0){ toolTipSTYLE.display = "none";} } if (bT){ if (document.all("msg1").filters[2].status==1 || document.all("msg1").filters[2].status==0){ toolTipSTYLE.display = "none";} } if (!rT && !bT) toolTipSTYLE.display = "none"; //---------------------- } } else // show { if(!fg) fg = "#777777"; if(!bg) bg = "#eeeeee"; var content = '<table id="msg1" name="msg1" border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '" class="trans_msg"><td>' + '<table border="0" cellspacing="0" cellpadding="3" bgcolor="' + bg + '"><td width=' + tw + '><font face="Arial" color="' + fg + '" size="-2">' + msg + '&nbsp\;</font></td></table></td></table>'; if(ns4) { toolTipSTYLE.document.write(content); toolTipSTYLE.document.close(); toolTipSTYLE.visibility = "visible"; } if(ns6) { document.getElementById("toolTipLayer").innerHTML = content; toolTipSTYLE.display='block' } if(ie4) { document.all("toolTipLayer").innerHTML=content; toolTipSTYLE.display='block' //--图象过渡,淡入处理-- var cssopaction=document.all("msg1").filters[0].opacity document.all("msg1").filters[0].opacity=0; if (rT) document.all("msg1").filters[1].Apply(); if (bT) document.all("msg1").filters[2].Apply(); document.all("msg1").filters[0].opacity=cssopaction; if (rT) document.all("msg1").filters[1].Play(); if (bT) document.all("msg1").filters[2].Play(); //---------------------- } } } function moveToMouseLoc(e) { if(ns4||ns6) { x = e.pageX; y = e.pageY; } else { x = event.x + document.body.scrollLeft; y = event.y + document.body.scrollTop; } toolTipSTYLE.left = x + offsetX; toolTipSTYLE.top = y + offsetY; return true; } </script> <style type="text/css"> <!-- .trans_msg { filter:alpha(opacity=100,enabled=1) revealTrans(duration=.2,transition=1) blendtrans(duration=.2); } --> </style> </head> <script> </script> <body> <div id="toolTipLayer" style="position:absolute; visibility: hidden"></div> <script>initToolTips()</script> <font face="Arial"> <a href="#" onMouseOver="toolTip('这是个好东东<br>你说呢<br>哈哈')" onMouseOut="toolTip()">test</a></font> <font face="Arial"> <a href="#" onMouseOver="toolTip('你要吗,好好用的哦真的', '#FFFF00', 'red')" onMouseOut="toolTip()">test</a></font> <font face="Arial"> <a href="#" onMouseOver="toolTip('这是个好东东<br>你说呢<br>哈哈', '#FFFF00', 'orange')" onMouseOut="toolTip()">test</a></font> <font face="Arial"> <a href="#" onMouseOver="toolTip('<marquee>跑啊!!跑</marquee>', '#FFFF00', 'orange')" onMouseOut="toolTip()">test</a></font> </body>[/code] //////////////////////////////////////// /////// 更多 //////////////////////////////////////// [code]<script> var oPopup = window.cr&#101;atePopup(); function rdl_doClick(){ var oMessage=document.all("oMessage"); with (oPopup.document.body) { style.backgroundColor="lightyellow"; style.border="solid black 1px"; innerHTML=oMessage.value; } oPopup.show(70, 70, 180, 60); } </script> <input id=oMessage type=text size=40 value="点击弹出窗口外面的区域关闭它。"> <br><br> <a href="#" onmouseover="rdl_doClick()" onmouseout="oPopup.hide();">显示弹出窗口 </a>[/code] 还有用titile[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <STYLE type=text/css>BODY { MARGIN-TOP: 0px; FONT-SIZE: 9pt; MARGIN-LEFT: 4px; MARGIN-RIGHT: 0px; FONT-FAMILY: "宋体" } A { FONT-WEIGHT: 400; FONT-SIZE: 13px; COLOR: black; TEXT-DECORATION: none } A:hover { FONT-WEIGHT: 400; FONT-SIZE: 13px; COLOR: red; TEXT-DECORATION: underline } A:active { FONT: 9pt "宋体"; CURSOR: hand; COLOR: #ff0033 } </style> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <script> function show(tips,flag,url){ var my_tips=document.all.mytips; if(flag){ my_tips.style.display=""; if (url!=null){my_tips.innerHTML="<img src='"+url+"'align=left>"+tips;} else{ my_tips.innerHTML=tips;} my_tips.style.left=event.clientX+10; my_tips.style.top=event.clientY+10; } else { my_tips.style.display="none"; } } </script> <a href="#" tips="自定义提示" onmousemove=show(this.tips,1) onmouseout=show(this.tips,0)>测试链接</a> <a href="#" tips="又一个自定义提示" onmousemove=show(this.tips,1,'http://be10.ods.org/51js/images/standard/online_member.gif') onmouseout=show(this.tips,0)>测试链接</a> <a href="#" tips="中华人民共和国中华人民共和国自定义提示" onmousemove=show(this.tips,1,'http://be10.ods.org/51js/images/standard/online_moderator.gif') onmouseout=show(this.tips,0)>测试链接</a> <div id=mytips style="position:absolute;width:150;height:16;border:1 gray solid;font-size:9pt;background-color:#ffffff;color:red;display:none;filter: progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3);"> </div> </body> </html> [/code] [code]<html> <head> <script Language="JavaScript"> //***********默认设置定义.********************* tPopWait=50;//停留tWait豪秒后显示提示。 tPopShow=5000;//显示tShow豪秒后关闭提示 showPopStep=20; popOpacity=99; //***************内部变量定义***************** sPop=null; curShow=null; tFadeOut=null; tFadeIn=null; tFadeWaiting=null; document.write("<style type='text/css'id='defaultPopStyle'>"); document.write(".cPopText { background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}"); document.write("</style>"); document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>"); function showPopupText(){ var o=event.srcElement; MouseX=event.x; MouseY=event.y; if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""}; if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""}; if(o.dypop!=sPop) { sPop=o.dypop; clearTimeout(curShow); clearTimeout(tFadeOut); clearTimeout(tFadeIn); clearTimeout(tFadeWaiting); if(sPop==null || sPop=="") { dypopLayer.innerHTML=""; dypopLayer.style.filter="Alpha()"; dypopLayer.filters.Alpha.opacity=0; } else { if(o.dyclass!=null) popStyle=o.dyclass else popStyle="cPopText"; curShow=setTimeout("showIt()",tPopWait); } } } function showIt(){ dypopLayer.className=popStyle; dypopLayer.innerHTML=sPop; popWidth=dypopLayer.clientWidth; popHeight=dypopLayer.clientHeight; if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24 else popLeftAdjust=0; if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24 else popTopAdjust=0; dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust; dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust; dypopLayer.style.filter="Alpha(Opacity=0)"; fadeOut(); } function fadeOut(){ if(dypopLayer.filters.Alpha.opacity<popOpacity) { dypopLayer.filters.Alpha.opacity+=showPopStep; tFadeOut=setTimeout("fadeOut()",1); } else { dypopLayer.filters.Alpha.opacity=popOpacity; tFadeWaiting=setTimeout("fadeIn()",tPopShow); } } function fadeIn(){ if(dypopLayer.filters.Alpha.opacity>0) { dypopLayer.filters.Alpha.opacity-=1; tFadeIn=setTimeout("fadeIn()",1); } } document.onmouseover=showPopupText; </script> </head> <BODY> <a href="#" title="我想请问斑竹?<br>作者:农民<br>发表于2002-6-3 20:17:16<br>最后跟贴:呵呵,是住我们......">我想请问斑竹?</a> 接着前面的 </body> </html> [/code] [code] <a href="#" title="蓝色理想">www.blueidea.com</a> <img src=/logo.gif alt="www.blueidea.com"> 由js控制的代码,还可以临时解决 alt 显示速度慢的问题 <SCRIPT language=JavaScript1.2> <!-- tPopWait=50; tPopShow=50000; showPopStep=10; popOpacity=100; sPop=null; curShow=null; tFadeOut=null; tFadeIn=null; tFadeWaiting=null; document.write("<style type='text/css'id='defaultPopStyle'>"); document.write(".cPopText { background-color: #FFFFFF; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}"); document.write("</style>"); document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>"); function showPopupText(){ var o=event.srcElement; MouseX=event.x; MouseY=event.y; if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""}; if(o.dypop!=sPop) { sPop=o.dypop; clearTimeout(curShow); clearTimeout(tFadeOut); clearTimeout(tFadeIn); clearTimeout(tFadeWaiting); if(sPop==null || sPop=="") { dypopLayer.innerHTML=""; dypopLayer.style.filter="Alpha()"; dypopLayer.filters.Alpha.opacity=0; } else { if(o.dyclass!=null) popStyle=o.dyclass else popStyle="cPopText"; curShow=setTimeout("showIt()",tPopWait); } } } function showIt(){ dypopLayer.className=popStyle; dypopLayer.innerHTML=sPop; popWidth=dypopLayer.clientWidth; popHeight=dypopLayer.clientHeight; if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24 else popLeftAdjust=0; if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24 else popTopAdjust=0; dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust; dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust; dypopLayer.style.filter="Alpha(Opacity=0)"; fadeOut(); } function fadeOut(){ if(dypopLayer.filters.Alpha.opacity<popOpacity) { dypopLayer.filters.Alpha.opacity+=showPopStep; tFadeOut=setTimeout("fadeOut()",1); } else { dypopLayer.filters.Alpha.opacity=popOpacity; tFadeWaiting=setTimeout("fadeIn()",tPopShow); } } function fadeIn(){ if(dypopLayer.filters.Alpha.opacity>0) { dypopLayer.filters.Alpha.opacity-=1; tFadeIn=setTimeout("fadeIn()",1); } } document.onmouseover=showPopupText; //--> </script> <img src="http://www.blueidea.com/img/common/logo.gif" alt="blue!dea welcome you"> [/code]