You can use Element.getStyle() in later versions of prototype.js <http://www.sergiopereira.com/articles/prototype.js.html>.
Best Matt > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Nicolas Terray > Sent: 16 February 2006 09:59 > To: rails-spinoffs@lists.rubyonrails.org > Subject: [Rails-spinoffs] Re: Retrieve a property defined in a css > > > On 2/16/06, Nicolas Terray <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I have a property, defined in an external stylesheet: > > > > .my_class { > > background-color: #FF0000; > > } > > > > > > I want to retrieve the value of this background-color of the class > > my_class. > > > > How can I do that with prototype/scriptaculous ? > > > > Thanks in advance, > > Nicolas Terray > > > > I've just found this script: > ---8<--------- > function getStyleClass (className) { > var re = new RegExp("\\." + className + "$", "gi"); > if (document.all) { > for (var s = 0; s < document.styleSheets.length; s++) > for (var r = 0; r < document.styleSheets[s].rules.length; r++) > if (document.styleSheets[s].rules[r].selectorText.search(re) > != -1) { > return document.styleSheets[s].rules[r].style; > } > } > else if (document.getElementById) { > for (var s = 0; s < document.styleSheets.length; s++) > for (var r = 0; r < > document.styleSheets[s].cssRules.length; r++) > if (document.styleSheets[s].cssRules[r].selectorText.search > (re) != -1) { > document.styleSheets[s].cssRules[r].sheetIndex = s; > document.styleSheets[s].cssRules[r].ruleIndex = s; > return document.styleSheets[s].cssRules[r].style; > } > } > else if (document.layers) > return document.classes[className].all; > return null; > } > function getStyleClassProperty (className, propertyName) { > var styleClass = getStyleClass(className); > if (styleClass) > return styleClass[propertyName]; > else > return null; > } > ---8<--------- > http://www.faqts.com/knowledge_base/view.phtml/aid/1939/fid/255 > > It works pretty find on Fx 1.0.7 and IE6 however I don't > understand all in this script. What does those lines mean : > document.styleSheets[s].cssRules[r].sheetIndex = s; > document.styleSheets[s].cssRules[r].ruleIndex = s; ??? > > As javascript experts, could you tell me if this script is > correct, not too old and unoptimizable ? > > Anyways, other suggestions are welcome! > > Thanks, > Nicolas Terray > _______________________________________________ > Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorized and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: http://www.rbos.com http://www.rbsmarkets.com ******************************************************************************** _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs