解决ie6下select框无法设置title alt 的问题

本文介绍了如何在IE6浏览器下解决Select元素的title属性异常显示的问题,通过自定义提示框的方式实现title提示的正常显示。适用于XP系统环境下IE6用户的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在ie6下设置select框的title或alt会抛出异常,在ie8下无此问题。而客户大多数还是使用xp系统,因此很多客户端都是ie6,因此title提示的问题还是要解决,解决办法如下

<html>
<SCRIPT> 
var innerhtm = '<div id="showtip" style="position:absolute;display:none;"><table style="background:#FDFDDF; border:1px solid #AFB799; font-family:verdana; font-size:70%;color=#111;" cellspacing="0"  cellpadding="0" border=0><tr><td style="height:18px;padding:3px;background:#147B95;FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#ffffff,endColorStr=#147B95,style=1;);"></td></tr><tr><td style="padding:4px;"></td></tr></table></div>';

document.write(innerhtm);

function showTitle(ev,title, content) 
{   
   ev = ev||window.event;
    var mousePos = mouseCoords(ev); 
    mpx=mousePos.x+6;
    mpy=mousePos.y+6;

    var divobj = document.getElementById("showtip");
    divobj.style.display = "block";
    divobj.style.left = mpx+"px";
    divobj.style.top = mpy+"px";
  
    divobj.getElementsByTagName("table")[0].rows[0].cells[0].innerHTML = title;
    divobj.getElementsByTagName("table")[0].rows[1].cells[0].innerHTML = content;
} 

function hideTitle(){
   document.getElementById("showtip").style.display = "none";  
}

function mouseCoords(ev){
    if(ev.pageX||ev.pageY){return {x:ev.pageX, y:ev.pageY};}
    return {x:ev.clientX + document.documentElement.scrollLeft,y:ev.clientY + document.documentElement.scrollTop}
}

</SCRIPT> 


<body style="background:#DAE1AB;">

 <select onmousemove="showTitle(event,'IP地址', '192.168.1.1<br>192.168.12.202<br>127.0.0.1');" onmouseout="hideTitle()">使用示例,将鼠标移动到这里</select>

</html>


 

效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值