Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access properties in Firefox 1

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
I like to use my own properties in certain elements then be able to access them using document.getElementById(). It works great in IE, but not Firefox.

<div id="mydiv" fileType="pdf">

var v1 = document.getElementById("mydiv");
alert(v1.fileType);

I get an alert window in IE with "pdf". In Firefox, I get "undefined". Any ideas how I can accomplish something like this in Firefox.

Thanks in advance.

ToddWW
 
IE wrongly detects non-standard attributes.

For all other browsers you need to use the getAttribute() function.

Code:
alert(v1.getAttribute('attributeName'));

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top