about DOM properties

Hi,

In Internet explorer you can create your own properties in DOM objects like this:
[code]

"
"

[/code]

You can acces them via JavaScript like this:
[code]
alert(document.myform.myAttribute);
[/code]

but when I use mozilla firefox I get an undefined... Is this a know isue ? Or am I dong something wrong ? Or shouldn't I be creating my own properties... ? I Use them for validation of my forms. I can set an attribute mandatory to true or false in my formfields etc...

hope someone can help me out here...

;-)
-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...

Comments

  • : Hi,
    :
    : In Internet explorer you can create your own properties in DOM objects like this:
    : [code]
    :
    : "
    : "
    :
    : [/code]
    :
    : You can acces them via JavaScript like this:
    : [code]
    : alert(document.myform.myAttribute);
    : [/code]
    :
    : but when I use mozilla firefox I get an undefined... Is this a know isue ? Or am I dong something wrong ? Or shouldn't I be creating my own properties... ? I Use them for validation of my forms. I can set an attribute mandatory to true or false in my formfields etc...
    :
    : hope someone can help me out here...
    :
    : ;-)
    : -mac-
    : mailto:mac_doggie@hotmail.com
    : the Netherlands...
    :
    :
    DOM is a technology designed by MS and not very well supported by other non-MS browsers. This is known issue and due MS's policies will probably not be resolved very quickly.
    There are two possible solutions: warn users about the coding and suggest that they use IE to explore your page; or find a way around it, possibly by defining your attributes in a 2D-array which accompanies your page.
  • You should never make your page require a particular browser. I don't even have IE, so any page which only works in it I can't view.

    The problem is that Mozilla/Firefox doesn't use names as child properties of the document. I'd assume that's according to the W3C standard, and imagine the problems if you named an element after a built-in property. You could loop through every element with document.getElementsByTagName(*) and find one with the name attribute set to whatever, or you can use document.getElementById('id') and give them IDs rather than names (which also prevents giving two elements the same name). You could also try document.getElementsByName('name'), but I don't know if IE or Opera support it. Note that it should return a list of elements in case you do share them, so you'll have to do document.getElementsByName('myform')[0] to access the element named myform.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories