友
我注意到在Firefox v23.0.1中,HTMLElement的hasOwnProperty
(输入,按钮等等)不起作用,
button1.hasOwnProperty('id') = false
我用来检查:
var str1 = '';
for (pp in button1) {
if (button1.hasOwnProperty(pp)) {
str1 += (',' + pp);
}
}
alert(str1);//nothing here
但是在chrome hasOwnProperty中效果很好。
你知道这是一个错误吗?答案 0 :(得分:5)
根据规范,“id”属性位于HTMLElement.prototype或Element.prototype上(取决于规范版本)。
Firefox得到了这个权利。 Chrome会将所有属性直接放在对象上。
<小时/> http://dev.w3.org/2006/webapi/WebIDL/#es-attributes http://dev.w3.org/2006/webapi/WebIDL/#ecmascript-binding