问题描述
<scripttype="text/javascript">functionenableTooltips(id){varlinks,i,h;if(!document.getElementById||!document.getElementsByTagName)return;h=document.createElement("span");h.id="btc";h.setAttribute("id","btc");h.style.position="absolute";document.getElementsByTagName("body")[0].appendChild(h);if(id==null)links=document.getElementsByTagName("img");elselinks=document.getElementById(id).getElementsByTagName("img");for(i=0;i<links.length;i++){Prepare(links[i]);}}functionPrepare(el){vartooltip,t,b,s,l;t=el.getAttribute("message");if(t==null||t.length==0)return;el.removeAttribute("message");tooltip=CreateEl("span","tooltip");s=CreateEl("span","top");s.innerHTML=t;tooltip.appendChild(s);l=el.getAttribute("href");if(l.length>30)l=l.substr(0,27)+"...";setOpacity(tooltip);el.tooltip=tooltip;el.onmouseover=showTooltip;el.onmouseout=hideTooltip;el.onmousemove=Locate;}functionshowTooltip(e){document.getElementById("btc").appendChild(this.tooltip);Locate(e);}functionhideTooltip(e){vard=document.getElementById("btc");if(d.childNodes.length>0)d.removeChild(d.firstChild);}functionsetOpacity(el){el.style.filter="alpha(opacity:95)";el.style.KHTMLOpacity="0.95";el.style.MozOpacity="0.95";el.style.opacity="0.95";}functionCreateEl(t,c){varx=document.createElement(t);x.className=c;x.style.display="block";return(x);}functionLocate(e){varposx=0,posy=0;if(e==null)e=window.event;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}elseif(e.clientX||e.clientY){if(document.documentElement.scrollTop){posx=e.clientX+document.documentElement.scrollLeft;posy=e.clientY+document.documentElement.scrollTop;}else{posx=e.clientX+document.body.scrollLeft;posy=e.clientY+document.body.scrollTop;}}document.getElementById("btc").style.top=(posy+10)+"px";document.getElementById("btc").style.left=(posx-20)+"px";}</script>
解决方案
解决方案二:
大家帮帮忙哈。。。
解决方案三:
不知道你是什么IE,反正IE8里面我也没有看见有什么!
解决方案四:
<html><scripttype="text/javascript">functionenableTooltips(id){varlinks,i,h;if(!document.getElementById||!document.getElementsByTagName)return;h=document.createElement("span");h.id="btc";h.setAttribute("id","btc");h.style.position="absolute";document.getElementsByTagName("body")[0].appendChild(h);if(id==null)links=document.getElementsByTagName("img");elselinks=document.getElementById(id).getElementsByTagName("img");for(i=0;i<links.length;i++){Prepare(links[i]);}}functionPrepare(el){vartooltip,t,b,s,l;t=el.getAttribute("message");if(t==null||t.length==0)return;el.removeAttribute("message");tooltip=CreateEl("span","tooltip");s=CreateEl("span","top");s.innerHTML=t;tooltip.appendChild(s);l=el.getAttribute("href");if(l.length>30)l=l.substr(0,27)+"...";setOpacity(tooltip);el.tooltip=tooltip;el.onmouseover=showTooltip;el.onmouseout=hideTooltip;el.onmousemove=Locate;}functionshowTooltip(e){document.getElementById("btc").appendChild(this.tooltip);Locate(e);}functionhideTooltip(e){vard=document.getElementById("btc");if(d.childNodes.length>0)d.removeChild(d.firstChild);}functionsetOpacity(el){el.style.filter="alpha(opacity:95)";el.style.KHTMLOpacity="0.95";el.style.MozOpacity="0.95";el.style.opacity="0.95";}functionCreateEl(t,c){varx=document.createElement(t);x.className=c;x.style.display="block";return(x);}functionLocate(e){varposx=0,posy=0;if(e==null)e=window.event;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}elseif(e.clientX||e.clientY){if(document.documentElement.scrollTop){posx=e.clientX+document.documentElement.scrollLeft;posy=e.clientY+document.documentElement.scrollTop;}else{posx=e.clientX+document.body.scrollLeft;posy=e.clientY+document.body.scrollTop;}}document.getElementById("btc").style.top=(posy+10)+"px";document.getElementById("btc").style.left=(posx-20)+"px";}</script><scripttype="text/javascript">window.onload=function(){enableTooltips()};</script><styletype="text/css">.tooltip{width:200px;color:#000;font:lighter11px/1.3Arial,sans-serif;text-decoration:none;text-align:center}.tooltip{width:200px;color:#000;font:lighter11px/1.3Arial,sans-serif;text-decoration:none;text-align:center}.tooltipspan.top{text-align:left;text-indent:1em;padding:30px8px;}.tooltipb.bottom{padding:3px8px15px;color:#548912;}#container{width:200px;height:100px;}#containerimg{float:left;}</style><divid="container"><imgsrc='a.gif'message="<imgsrc='4.jpg'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img></div></html>这个是全部代码,麻烦看看啊。在火狐里面没反应。
解决方案五:
把l=el.getAttribute("href");改成l=el.getAttribute("src");试试,火狐在这里报错了
解决方案六:
l=el.getAttribute("href");if(l.length>30)l=l.substr(0,27)+"...";img标签没有href属性。l=nullnull.length出错
解决方案七:
把26行改为l=el.getAttribute("src");即可<html><scripttype="text/javascript">functionenableTooltips(id){varlinks,i,h;if(!document.getElementById||!document.getElementsByTagName)return;h=document.createElement("span");h.id="btc";h.setAttribute("id","btc");h.style.position="absolute";document.getElementsByTagName("body")[0].appendChild(h);if(id==null)links=document.getElementsByTagName("img");elselinks=document.getElementById(id).getElementsByTagName("img");for(i=0;i<links.length;i++){Prepare(links[i]);}}functionPrepare(el){vartooltip,t,b,s,l;t=el.getAttribute("message");if(t==null||t.length==0)return;el.removeAttribute("message");tooltip=CreateEl("span","tooltip");s=CreateEl("span","top");s.innerHTML=t;tooltip.appendChild(s);l=el.getAttribute("src");if(l.length>30)l=l.substr(0,27)+"...";setOpacity(tooltip);el.tooltip=tooltip;el.onmouseover=showTooltip;el.onmouseout=hideTooltip;el.onmousemove=Locate;}functionshowTooltip(e){document.getElementById("btc").appendChild(this.tooltip);Locate(e);}functionhideTooltip(e){vard=document.getElementById("btc");if(d.childNodes.length>0)d.removeChild(d.firstChild);}functionsetOpacity(el){el.style.filter="alpha(opacity:95)";el.style.KHTMLOpacity="0.95";el.style.MozOpacity="0.95";el.style.opacity="0.95";}functionCreateEl(t,c){varx=document.createElement(t);x.className=c;x.style.display="block";return(x);}functionLocate(e){varposx=0,posy=0;if(e==null)e=window.event;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}elseif(e.clientX||e.clientY){if(document.documentElement.scrollTop){posx=e.clientX+document.documentElement.scrollLeft;posy=e.clientY+document.documentElement.scrollTop;}else{posx=e.clientX+document.body.scrollLeft;posy=e.clientY+document.body.scrollTop;}}document.getElementById("btc").style.top=(posy+10)+"px";document.getElementById("btc").style.left=(posx-20)+"px";}</script><scripttype="text/javascript">window.onload=function(){enableTooltips()};</script><styletype="text/css">.tooltip{width:200px;color:#000;font:lighter11px/1.3Arial,sans-serif;text-decoration:none;text-align:center}.tooltip{width:200px;color:#000;font:lighter11px/1.3Arial,sans-serif;text-decoration:none;text-align:center}.tooltipspan.top{text-align:left;text-indent:1em;padding:30px8px;}.tooltipb.bottom{padding:3px8px15px;color:#548912;}#container{width:200px;height:100px;}#containerimg{float:left;}</style><divid="container"><imgsrc='a.gif'message="<imgsrc='4.jpg'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img><imgsrc='a.gif'message="<imgsrc='a.gif'/>"></img></div></html>
解决方案八:
还在用古老的IE6啊。用谷歌火狐做测试吧。作为设计者,要为推动古老的文明古国往前发展啊。还没让IE6折磨够啊啊!