|
制作类似于Title、ALT的提示效果(1) 在网页中,有时我们将鼠标移到图片上,或者文字链接处,会出现文字型的提示信息。一般制作这样的效果极为简单,只需在图片代码中加入<Alt="文字提示信息">或者在文字链接代码中加入<Title="文字提示信息">。仔细观察一下,感觉出现的信息总有时间上的停顿。如何制作类似于It365cn.com首页文字超链接的提示信息的效果呢?
制作方法一:加入JS代码 1、在页面的<head></head>中加入JS代码: <script language="Javascript"> var tipTimer; function locateObject(n, d) { //v3.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=locateObject(n,d.layers[i].document); return x; }
function hideTooltip(object) { if (document.all) { locateObject(object).style.visibility="hidden" locateObject(object).style.left = 1; locateObject(object).style.top = 1; return false } else if (document.layers) { locateObject(object).visibility="hide" locateObject(object).left = 1; locateObject(object).top = 1; return false } else return true }
function showTooltip(object,e, tipContent, backcolor, bordercolor, textcolor, displaytime) { window.clearTimeout(tipTimer)
if (document.all) { locateObject(object).style.top=document.body.scrollTop+event.clientY+20
locateObject(object).innerHTML='<table style="font-family: Verdana,Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; border: '+bordercolor+'; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: '+backcolor+'" width="10" border="0" cellspacing="1" cellpadding="1"><tr><td nowrap><font style="font-family: Verdana,Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table> '
|