@Rick
elParent and el are names (id's).
Tried your solution but only one style get copied.
Accordingly to quirksmode, #setAttribute implementation in IE 7 and
lower is incomplete (http://www.quirksmode.org/dom/
w3c_core.html#attributes). Therefore I prefer base my application on a
framework ;-)

@Kangax
I've build a loading element that can be bound to any part (element)
of the page, overlying the parentEl in an absolute manner. I need to
directly copy the style value (of the element's attribute) when
parentEl is dynamically styled and hidden (display:none;).

Your solution removes the undefined attribute (in DOM) but now I'm
ending with an empty one.
To be as clear as possible;
Before: undefined=""
Now: =""

Can it be a synchronisation error? As the current style of parentEl is
not yet reflected in the DOM?

BTW I've got now an hybrid solution, using your direct copy of the
object's (CSSStyleDeclaration) properties when #clonePosition crashes
in IE.

On May 1, 12:37 am, kangax <kan...@gmail.com> wrote:
> On Apr 30, 10:13 am, bazikch <bazik...@gmail.com> wrote:
>
> > Hello,
>
> > I'm trying to do the following:
> > $(el).writeAttribute('style', $(elParent).readAttribute('style'));
>
> It would be helpful if you explained what it is exactly that are you
> trying to accomplish.
>
> The line above actually ends up jumping through dozens of hoops,
> working around IE's broken attribute model (and defective (get|set)
> Attribute). In its core, `readAttribute` relies on `getAttribute`;
> `getAttribute('style')`, in its turn, returns a value of *an actual
> "style" attribute*. If an element you're querying it from does not
> have `style` attribute, getAttribute/readAttribute will return `null`.
> Otherwise, it will return a string with a value of that attribute. IE,
> of course, returns an actual style object (not the string value) as it
> does not differentiate between element attributes and properties.
>
> To get an actual representation of style attribute you would need to
> access `style` property of an element, which returns
> CSSStyleDeclaration object. It's good to remember that this
> representation only contains values that are explicitly set in
> element's `style` attribute. It does not return computed style values
> (which browser calculates based on cascading rules and resolution of
> relative values).
>
> If what you really want to do is copy styles of one element to another
> one, then you can always iterate over certain set of properties (that
> you're interested in) of a `style` object and assign their values to
> same-named properties of another element's `style` object:
>
> var props = ['top', 'left', 'width', 'height'],
>       i = props.length;
> while (i--) {
>   el.style[props[i]] = parentEl.style[props[i]];
>
> }
>
> Note that this will only work with values set explicitly in a `style`
> attribute (and not those declared in, say, inline or linked
> stylesheets).
>
> [...]
>
> --
> kangax
--~--~---------~--~----~------------~-------~--~----~
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 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to