实现Title Alt功能可以显示图片[1]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 jimbor 的 blog


<html>
<head>
  <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> '

if ((e.x + locateobject(object).clientwidth) > (document.body.clientwidth + document.body.scrollleft))
{
locateobject(object).style.left = (document.body.clientwidth + document.body.scrollleft) - locateobject(object).clientwidth-10;
}
else
{
locateobject(object).style.left=document.body.scrollleft+event.clientx
}
locateobject(object).style.visibility="visible"
tiptimer=window.settimeout("hidetooltip('"+object+"')", displaytime);
return true;
}
else if (document.layers)
{
locateobject(object).document.write('<table width="10" border="0" cellspacing="1" cellpadding="1"><tr bgcolor="'+bordercolor+'"><td><table width="10" border="0" cellspacing="0" cellpadding="2"><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: verdana,tahoma, arial, helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipcontent)+'</font></td></tr></table></td></tr></table>')
locateobject(object).document.close()
locateobject(object).top=e.y+20

if ((e.x + locateobject(object).clip.width) > (window.pagexoffset + window.innerwidth))
{
locateobject(object).left = window.innerwidth - locateobject(object).clip.width-10;
}
else
{
locateobject(object).left=e.x;
}
locateobject(object).visibility="show"
tiptimer=window.settimeout("hidetooltip('"+object+"')", displaytime);
return true;
}
else
{
return true;
}
}
</script>
  </head>
  <body>
<div id="dhtmltooltip" style="position: absolute; visibility: hidden; width:10; height: 10; z-index: 1000; left: 0; top: 0"></div>
<span onmouseover="showtooltip('dhtmltooltip',event, '文字提示信息部分<br>jimbor studio<img src = 1.jpg height=120>', '#fffff2','#000000','#000000','20000')" onmouseout="hidetooltip('dhtmltooltip')">点这里</span>
</body>
<html>


如下效果
 

  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top