Hello I''d like to get all the CSS properties and values of an element. There''s a function Element.getStyle in Prototype (http:// wiki.script.aculo.us/scriptaculous/show/Element.getStyle), unfortunately it only returns the value of one property, which you have to specify as a function parameter. Is there a way to get all the style using Prototype or Scriptaculous? Best regards Havocado --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Havocado a écrit :> have to specify as a function parameter. Is there a way to get all the > style using Prototype or Scriptaculous?Since what you require constitutes, technically, the whole computed style for the element, and because this feature only exists within DOM Level 2 CSS (and later), using the AbstractView interface defined in DOM Level 2 Views, there''s no reason to provide a wrapper. Use: document.defaultView.getComputedStyle(element, null) This will return a CSSStyleDeclaration implementation, which you can use as a sort of hash object and/or list for all computed CSS properties. It must be widespread enough, as getStyle relies on it when it finds no inline style. Read the spec [1] for more details. [1] http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-OverrideAndComputed -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You''re right, but as far as I know, Internet Explorer uses element.currentStyle instead of document.defaultView.getComputedStyle . Also, in the prototype''s getStyle function there some more javascript code, fixing some of the CSS values. So, it''s not just document.defaultView.getComputedStyle, it''s also element.currentStyle plus all this fixing magic. This can really call for a wrapper, don''t you think? On 21 Mar, 23:27, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Havocado a écrit : > > > have to specify as a function parameter. Is there a way to get all the > > style using Prototype or Scriptaculous? > > Since what you require constitutes, technically, the whole computed > style for the element, and because this feature only exists within DOM > Level 2 CSS (and later), using the AbstractView interface defined in DOM > Level 2 Views, there''s no reason to provide a wrapper. Use: > > document.defaultView.getComputedStyle(element, null) > > This will return a CSSStyleDeclaration implementation, which you can use > as a sort of hash object and/or list for all computed CSS properties. > It must be widespread enough, as getStyle relies on it when it finds no > inline style. Read the spec [1] for more details. > > [1]http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-OverrideAndComputed > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
My bad. getStyle gets redefined for MSIE, indeed. Plus, there''s the float/cssFloat thing, the opacity/filter thing, the conversion to float, the auto values for width and height on displayed elements... Yeah, gruesome work. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---