Actually just using the .id property worked well enough for my
purposes. I took the long way to the short path :)

On Feb 12, 2:16 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> Doctuh wrote:
> > ...
>
> > <form id="foo">
> >  <input type="hidden" name="id' value="bar" />
> > </form>
>
> > If you have a form with a hidden form element named 'id', and you try
> > to use readAttribute() on the form you will get two different
> > responses:
>
> > IE gives you an Object (the input object named 'id')
> > Firefox gives you 'foo'.
>
> > IE will give you 'foo' if there is not a overriding form element.
>
> > ...
>
> I can confirm that using element.id, element.readAttribute('id'), and
> element.getAttribute('id') will always return the same thing as the most
> explicit form-element access: document.forms[0].elements['id'];  In
> fact, "foo" doesn't seem to be a value for any attribute of the form
> node--when I iterate through the properties of the foo form, for
> example, the text "foo" does not show up anywhere.  I don't know of any
> function besides getAttribute that should return it.  Somehow the 'id'
> node (the hidden input) in the form's elements collection overwrites the
> form node id.
>
> I don't know if there is a good way to normalize this behavior for IE
> without checking for a form tag and using something hackish like a regex
> on outerHTML. For example, the code below uses outerHTML and works at
> least for the case you provided.
>
> - Ken Snyder
>
> Element.addMethods('form', {
>   readAttribute: function(element, name) {
>     element = $(element);
>     if (Prototype.Browser.IE) {
>
>       // begin new section
>       if (typeof element[name] == 'object') {
>         var match = new RegExp(RegExp.escape(name) + '=([^
>  >]+)').exec(element.outerHTML);
>         if (match) return match[1];
>       }
>       // end new section
>
>       var t = Element._attributeTranslations.read;
>       if (t.values[name]) return t.values[name](element, name);
>       if (t.names[name]) name = t.names[name];
>       if (name.include(':')) {
>         return (!element.attributes || !element.attributes[name]) ? null :
>          element.attributes[name].value;
>       }
>     }
>     return element.getAttribute(name);
>   }
>
> });
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to