简体   繁体   English

如何在Firefox JavaScript中访问非标准属性?

[英]How do you access non-standard attributes in Firefox JavaScript?

Basically in IE you can do something like this: 基本上在IE中,您可以执行以下操作:

<img metaDataAtt="type5" src="..." id="tag1"/>

and then in the JavaScript do something like 然后在JavaScript中执行类似

var theImg = document.getElementById("tag1");
alert(theImg.metaDataAtt);

However, in firefox you can't. 但是,在Firefox中不能。 Is there some sort of hack to get around this? 是否有某种解决方法?

Thanks, Grae 谢谢Grae

document.getElementById('tag1').getAttribute('metaDataAtt');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM