IE事件处理程序没效果,提示“Object doesn't support property or method 'attachEvent'”

来源:2-4 IE事件处理程序及跨浏览器解决

阿宅娘

2018-03-30 09:55

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.ee{text-decoration:line-through; text-decoration:underline; }
</style>
</head>

<body>


<input type="button" id="btn3" value="按下去3">

<script type="text/javascript">
function ee(){
    alert("Hello Haa!");
    }
var btn3 = document.getElementById("btn3");
btn3.attachEvent('onclick',ee);

</script>

</body>
</html>


写回答 关注

1回答

  • Dong大瓜
    2018-04-01 17:26:14

    你用的是什么浏览器打开attachEvent是老版本IE的东西了,也就是说为了兼容老版本的IE才用的,好像是IE8以下吧

    阿宅娘

    我是用IE开发者工具中的仿真,模拟IE8。IE8以下包不包含IE8的?

    2018-04-02 08:57:33

    共 1 条回复 >

DOM事件探秘

DOM事件?本课程会通过实例来给小伙伴们讲解如何使用这些事件

99533 学习 · 1207 问题

查看课程

相似问题