IE里的attachEvent不好用啊, 谁来帮我改一改.
注:不要用onmouseout=function(){}这种的,因为我要添加多个事件处理器.
---------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script defer="defer">
function hightlight(obj)
{
obj.style.backgroundColor='#999999';
}
function normal(obj)
{
obj.style.backgroundColor='';
}
for(var i=1;i<=3;i++)
{
var obj = document.getElementById('item'+i);
obj.attachEvent('onmouseover',function(){hightlight(obj)});
obj.attachEvent('onmouseout',function(){normal(obj)});
}
</script>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td id="item1"> </td>
</tr>
<tr>
<td id="item2"> </td>
</tr>
<tr>
<td id="item3"> </td>
</tr>
</table>
</body>
</html>
...全文
相关推荐
IE11没有window.attachEvent方法处理方法
IE11没有window.attachEvent方法处理方法,文档中有详细说明
attachEvent和addEventListener 使用方法
NULL 博文链接:https://zhang-yingjie-qq-com.iteye.com/blog/321486
attachEvent的使用方法与传递参数[IE|firefox]|angluo-javascript-37392.pdf
attachEvent的使用方法与传递参数[IE|firefox]
javascript attachEvent和addEventListener使用方法
attachEvent与addEventListener区别适应的浏览器版本不同,同时在使用的过程中要注意
self.attachevent is not a function的解决方法
注意原因: window对象的attachEvent方法只在IE浏览器中有效,其它浏览器不支持这个方法,所以报错。 self.attachevent is not a function其实就是以前的代码, 没有做chrome、firefox浏览器兼容导致。 self.attachEvent("onblur",function(){dd.style.display="none"}) 上面的代码在chrome浏览器肯定会报错的。 因为chrome浏览器绑定事件不支持attachevent而支持addEventListener。 下面是临时解决方法: if(!self.addEventListe


