case:
<html>
<script>
if(!document.attachEvent)
{
document.attachEvent = function(){document.addEventListener(arguments[0].substr(2),arguments[1],arguments[2])}
}
document.attachEvent("onmouseover",function(e)
{
var tip = "";
if(typeof(event)=="undefined"){
//firfox works fine
tip = e.target.getAttribute("tips")
}else{
// a ie bug: id and name seem to mixed
tip = event.srcElement.getAttribute("tips");
}
alert(tip);
});
</script>
<body>
<input type=checkbox id=a1 name=a1 tips=''>a1<br>
<input type=checkbox id=a2 name=a2 tips=''>a2<br>
<input type=checkbox id=a3 name=a5 tips=''>a3<br>
<input type=checkbox id=a4 name=a3 tips=''>a4<br>
<input type=checkbox id=a5 name=a4 tips=''>a5<br>
<script>
var i;
for (i=1; i<=5; i++){
document.getElementById("a"+i).setAttribute("tips","A"+i);
}
</script>
</body>
</html>
as this code, e.srcElement should be the source element of mouseover's target.
but it may refer to another element.
the tips for the 5 checkbox should be A1,A2,A3,A4,A5 but in ie, is A1,A2,A5,A4,""
change names to b1,b2,b3,b4,b5 will cover the problem.
neoemdund,2006/May/14
-----
没有评论:
发表评论