<!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=utf-8" />
<title>IE6用setAttribute添加事件无效</title>
<style type="text/css">
* {margin:0;padding:0;margin:0 auto;}
#div1{width:200px; height:200px;background:#F03;}
</style>
</head>
<body>
<div id="div1"></div>
<script type="text/javascript">
function method(){
alert(1);
}
var ids = "div1";
document.getElementById(ids).setAttribute("onclick","method()");
//document.getElementById(ids).setAttribute("onclick",method); //无效
</script>
</body>
</html>
在IE6 下无法响应该事件
IE7+、chorome、Firefox 条件下正常,会响应onclick事件!
分享到:
相关推荐
IE6、IE7中setAttribute不支持class/for/rowspan/colspan等属性的说明,需要的朋友可以参考下。
博客园闪存分页是用JavaScript生成的,今天发现在IE8下点击页码不能翻页,翻页操作是在当前页码的...由于IE8不支持setAttribute方法,这里添加的onclick事件处理程序并未添加上。 后来改为jQuery的attr方法: 代码如
JS动态添加事件的方法有很多,我们可以使用setAttribute、attachEvent 和 addEventListener等等,感兴趣的朋友可以参考下
复制代码代码如下: table { border-collapse:collapse; border-spacing:0; } th,td { padding: 0; } JS操作这两个属性有两种方式...复制代码代码如下: table.setAttribute(‘cellspacing’,’10’); table.setAttribu
我们经常需要在JavaScript中给Element动态添加各种属性,这可以通过使用setAttribute()来实现,这就涉及到了浏览器的兼容性问题
The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, double) y2ssh.sg.chp1.action.AddAction.execute(AddAction.java:18) y2ssh.sg.chp1....
这里利用 setAttribute 指定 onclick 属性,简单,很好理解, 但是:IE 不支持,IE 并不是不支持 setAttribute 这个函数,而是不支持用 setAttribute 设置某些属性,包括对象属性、集合属性、事件属性,也就是说用 ...
主要介绍了javascript中setAttribute()函数使用方法及兼容性的相关资料,需要的朋友可以参考下
测试环境(客户端浏览器 ) IE6,IE7, IE8兼容模式, IE8 Firefox 3.6.8, google chrome 5.0.375.125 先来说明两个函数的标准定义。 elementNode.setAttribute(name,value) name 必需。规定要设置的属性名。 value ...
假设,我们要使用setAttribute来... 在IE下使用 如果在IE下给DOM setAttribute(“class”) 使用IE Developer看结构会发现,DOM上面显示了两个class出来… 原来IE是把自定义的class和系统的class是区分开的。- -b
代码如下: var asubmit = document.... //在火狐中有效,而在ie中无效 代码如下: <span xss=removed> asubmit.setAttribute(“onclick”,”[removed]document.buyform.submit();”);</span> //在ie中有效,火
IE中则必须使用style.cssText var dom=document.getElementById(“name”); dom1.style.cssText = “width:10px;height:10px;border:solid 1px red;”; 补充一下,目前style.cssText类似innerHTML了,已经成为一个
本文实例分析了javascript中setAttribute兼容性用法。分享给大家供大家参考,具体如下: 1:常规属性建议使用 node.XXXX。 2:自定义属性建议使用node.getAttribute(“XXXX”)。 3:当获取的目标是JS里的关键字时建议...
今天小编就为大家分享一篇关于PDO::setAttribute讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
今天小编就为大家分享一篇关于PHP PDOStatement::setAttribute讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧