Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.westnet.com.au!news.westnet.com.au.POSTED!not-for-mail NNTP-Posting-Date: Fri, 10 Feb 2012 06:48:28 -0600 Date: Fri, 10 Feb 2012 23:48:19 +1100 From: Andrew Poulos User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 Newsgroups: comp.lang.javascript Subject: Re: getComputedStyle vs currentStyle with IE 9 References: <2541188.UZlinSPExI@PointedEars.de> In-Reply-To: <2541188.UZlinSPExI@PointedEars.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0ZKdnfcGHO2Bj6jSnZ2dnUVZ_rSdnZ2d@westnet.com.au> Lines: 27 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 124.168.23.144 X-Trace: sv3-Lo9z3L1hkzQnNqh3rXl8OPhuGEjJ4/+TzrwpK5Dw6v6jWkAwPw6JrqxsXD8ERnww4N1W4QZq68PdNMa!AE+xP+JSt7Eov7VsEhrGqit9AI+M1Bi9yGk6xkQ93tFrz4NAoh2XxFfWVipfi8ZESGjFd2/pvyka!YShAvUAPglq4qAr0E0/law== X-Complaints-To: abuse@westnet.com.au X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1982 Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:11559 On 10/02/2012 11:38 PM, Thomas 'PointedEars' Lahn wrote: > Andrew Poulos wrote: > >> Alas, IE 9 supports window.getComputedStyle but not camel-cased CSS >> property names. So I tried this >> >> function getElStyle(el, IEcssPropName, cssPropName) { >> if (window.getComputedStyle) { >> return document.defaultView.getComputedStyle(el, >> null).getPropertyValue(cssPropName) || >> document.defaultView.getComputedStyle(el, >> null).getPropertyValue(IEcssPropName); >> >> } else if (el.currentStyle) { >> return el.currentStyle[IEcssPropName]; >> } >> >> return null; >> } >> >> and it seems to work. Is there a better way? > > Yes. Good, could you tell what it is? Andrew Poulos