danNL
01-24-2006, 02:15 PM
I've been working on a dynamic script using the DOM and wanted a routine that would parse out the element attribute collection. I came up with a routine that works in FireFox 1.5 and Opera 8, but it doesn't work in IE 6. Any ideas?
Thanks in advance for your help,
Dan
<html>
<head>
<title>DOM Element Properties</title>
<script language="javascript" type="text/javascript">
function objProp(x) {
elem = document.getElementById(x);
document.write(elem.attributes.length + "<br>");
for (i=0;i<elem.attributes.length;i++) {
if (elem.attributes[i].specified) { // to handle IE's 'user-specified' attribute collection
document.write(elem.attributes[i].name + "->" + elem.attributes[i].value + "<br>");
}
}
}
</script>
</head>
<body>
<img src="http://www.codingforums.com/images/icons/icon2.gif" alt="button0" width="16" height="16" border="0" id="btn0" onClick="objProp('btn0');"/> Click the arrow.
</body>
</html>
Thanks in advance for your help,
Dan
<html>
<head>
<title>DOM Element Properties</title>
<script language="javascript" type="text/javascript">
function objProp(x) {
elem = document.getElementById(x);
document.write(elem.attributes.length + "<br>");
for (i=0;i<elem.attributes.length;i++) {
if (elem.attributes[i].specified) { // to handle IE's 'user-specified' attribute collection
document.write(elem.attributes[i].name + "->" + elem.attributes[i].value + "<br>");
}
}
}
</script>
</head>
<body>
<img src="http://www.codingforums.com/images/icons/icon2.gif" alt="button0" width="16" height="16" border="0" id="btn0" onClick="objProp('btn0');"/> Click the arrow.
</body>
</html>