faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

28 of 30 people (93%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

In IE5 I could add user defined attributes to HTML TAGS. i.e. <INPUT type=text name=afieldname formattye=1001> can this be done in NS6?

Feb 16th, 2001 09:16
Mike Hall, brian corry,


Yes, the W3C DOM provides a method. Given this HTML:
 <div id="myDiv" myAttribute="myValue">Some text.</div>
You can find the attribute value in IE 5 or NS 6 like this:
var el = document.getElementById("myDiv");
alert(el.getAttribute("myAttribute"));
You can also use the element's attributes array.
The source link above points to a utility script I've developed that
will let you browse the DOM structure of a page. It can be to run with
both IE 5 and Netscape 6 against the same page to see how they differ.