<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Get the rendered style of an element</title>
	<atom:link href="http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/</link>
	<description>Web development and Internet trends</description>
	<pubDate>Fri, 29 Aug 2008 23:17:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Ryan Rampersad</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-372998</link>
		<dc:creator>Ryan Rampersad</dc:creator>
		<pubDate>Thu, 14 Aug 2008 05:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-372998</guid>
		<description>Thank you! element.style.height didn't work out for me and this helps! Thanks!</description>
		<content:encoded><![CDATA[<p>Thank you! element.style.height didn&#8217;t work out for me and this helps! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: July 24 Updated&#62;&#62; Keeping us Aware of the Traps of Bill-C61 - Wiihacks - Nintendo Wii Hacks Community</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-351525</link>
		<dc:creator>July 24 Updated&#62;&#62; Keeping us Aware of the Traps of Bill-C61 - Wiihacks - Nintendo Wii Hacks Community</dc:creator>
		<pubDate>Thu, 24 Jul 2008 15:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-351525</guid>
		<description>[...] Geist's Blog  /* Gets the rendered style of an element. * Credit and thanks to: Robert's Talk * Get the rendered style of an element - Robert&#8217;s talk - Web development and Internet trends * * Example usage: getStyle(document.getElementById("container"), "font-size"); */ function [...]</description>
		<content:encoded><![CDATA[<p>[...] Geist&#8217;s Blog  /* Gets the rendered style of an element. * Credit and thanks to: Robert&#8217;s Talk * Get the rendered style of an element - Robert&#8217;s talk - Web development and Internet trends * * Example usage: getStyle(document.getElementById(&#8221;container&#8221;), &#8220;font-size&#8221;); */ function [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keeping us Aware of the Traps of Bill-C61 - Wiihacks - Nintendo Wii Hacks Community</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-332003</link>
		<dc:creator>Keeping us Aware of the Traps of Bill-C61 - Wiihacks - Nintendo Wii Hacks Community</dc:creator>
		<pubDate>Mon, 07 Jul 2008 19:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-332003</guid>
		<description>[...] July 07, 2008     /* Gets the rendered style of an element. * Credit and thanks to: Robert's Talk * Get the rendered style of an element - Robert&#8217;s talk - Web development and Internet trends * * Example usage: getStyle(document.getElementById("container"), "font-size"); */ function [...]</description>
		<content:encoded><![CDATA[<p>[...] July 07, 2008     /* Gets the rendered style of an element. * Credit and thanks to: Robert&#8217;s Talk * Get the rendered style of an element - Robert&#8217;s talk - Web development and Internet trends * * Example usage: getStyle(document.getElementById(&#8221;container&#8221;), &#8220;font-size&#8221;); */ function [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Troy III</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-307892</link>
		<dc:creator>Troy III</dc:creator>
		<pubDate>Wed, 18 Jun 2008 15:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-307892</guid>
		<description>Reading this and that and those and what not, I come to one and only conclusion that is growing stronger and stronger everyday more. 

That IE is a Browser -  FX is a ridicule - while W3C is a godamn Dogma.</description>
		<content:encoded><![CDATA[<p>Reading this and that and those and what not, I come to one and only conclusion that is growing stronger and stronger everyday more. </p>
<p>That <acronym title="Internet Explorer">IE</acronym> is a Browser -  FX is a ridicule - while <acronym title="World Wide Web Consortium">W3C</acronym> is a godamn Dogma.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gunnar</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-288408</link>
		<dc:creator>Gunnar</dc:creator>
		<pubDate>Fri, 30 May 2008 13:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-288408</guid>
		<description>You saved my day!</description>
		<content:encoded><![CDATA[<p>You saved my day!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-287484</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Thu, 29 May 2008 17:32:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-287484</guid>
		<description>Wow, this is an awesome tip! Thanks, that helped me solve a huge problem that I had been trying to figure out for a while, thanks!</description>
		<content:encoded><![CDATA[<p>Wow, this is an awesome tip! Thanks, that helped me solve a huge problem that I had been trying to figure out for a while, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-286289</link>
		<dc:creator>Mario</dc:creator>
		<pubDate>Wed, 28 May 2008 15:22:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-286289</guid>
		<description>For top and left it returns auto which is not very useful.</description>
		<content:encoded><![CDATA[<p>For top and left it returns auto which is not very useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-274581</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Fri, 16 May 2008 06:47:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-274581</guid>
		<description>picmauri,

No problem at all. I'm glad to hear that it works for you now!</description>
		<content:encoded><![CDATA[<p>picmauri,</p>
<p>No problem at all. I&#8217;m glad to hear that it works for you now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: picmauri</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-274218</link>
		<dc:creator>picmauri</dc:creator>
		<pubDate>Thu, 15 May 2008 19:04:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-274218</guid>
		<description>Hi Robert,
Now is work fine.
The problem was a mismatch on the background-color value....the color value of an element with firefox is expressed with rgb (xxx,xxx,xxx) , while with IE7 the same value is expressed with #xxxxxx. However i had some error with another script.

TNX
and sorry for my english....I'm from Italy!</description>
		<content:encoded><![CDATA[<p>Hi Robert,<br />
Now is work fine.<br />
The problem was a mismatch on the background-color value&#8230;.the color value of an element with firefox is expressed with rgb (xxx,xxx,xxx) , while with IE7 the same value is expressed with #xxxxxx. However i had some error with another script.</p>
<p>TNX<br />
and sorry for my english&#8230;.I&#8217;m from Italy!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-273817</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Thu, 15 May 2008 08:36:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-273817</guid>
		<description>Picmauri,

The script should work in IE 7, so make sure you don't have any other error in there. The commented out line is only there to handle any potential error, so you can alert the value of e, to see what error you get.</description>
		<content:encoded><![CDATA[<p>Picmauri,</p>
<p>The script should work in <acronym title="Internet Explorer">IE</acronym> 7, so make sure you don&#8217;t have any other error in there. The commented out line is only there to handle any potential error, so you can alert the value of e, to see what error you get.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Picmauri</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-273793</link>
		<dc:creator>Picmauri</dc:creator>
		<pubDate>Thu, 15 May 2008 08:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-273793</guid>
		<description>I've tried the script on my project....with Firefox works Fine!
With Explorer 7 does not works!!!
.....try{
	strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
		return p1.toUpperCase();
	});
	strValue = oElm.currentStyle[strCssRule];
}
catch(e){
	// Used to prevent an error in IE 5.0 
}
....The line "// Used to prevent an error in IE 5.0" on statement catch Why is blank?
Have i to write some code in that line?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve tried the script on my project&#8230;.with Firefox works Fine!<br />
With Explorer 7 does not works!!!<br />
&#8230;..try{<br />
	strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){<br />
		return p1.toUpperCase();<br />
	});<br />
	strValue = oElm.currentStyle[strCssRule];<br />
}<br />
catch(e){<br />
	// Used to prevent an error in <acronym title="Internet Explorer">IE</acronym> 5.0<br />
}<br />
&#8230;.The line &#8220;// Used to prevent an error in <acronym title="Internet Explorer">IE</acronym> 5.0&#8243; on statement catch Why is blank?<br />
Have i to write some code in that line?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mihai copae</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-254966</link>
		<dc:creator>mihai copae</dc:creator>
		<pubDate>Tue, 22 Apr 2008 14:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-254966</guid>
		<description>If you want to parse the entire css for document u can use this:
&lt;code&gt;
n=document.styleSheets[0].cssRules.length
css_rules=document.styleSheets[0].cssRules

i=0;
while(i&#60;n){
    console.log(css_rules[i].cssText)
    i++;
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>If you want to parse the entire <acronym title="Cascading Style Sheets">CSS</acronym> for document u can use this:<br />
<code><br />
n=document.styleSheets[0].cssRules.length<br />
css_rules=document.styleSheets[0].cssRules</p>
<p>i=0;<br />
while(i&lt;n){<br />
    console.log(css_rules[i].cssText)<br />
    i++;<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-133976</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Wed, 07 Nov 2007 08:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-133976</guid>
		<description>iain,

I'm glad it helped! :-)</description>
		<content:encoded><![CDATA[<p>iain,</p>
<p>I&#8217;m glad it helped! <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iain</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-133777</link>
		<dc:creator>iain</dc:creator>
		<pubDate>Wed, 07 Nov 2007 00:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-133777</guid>
		<description>Thanks for this... exactly what I needed.

You absolute legend</description>
		<content:encoded><![CDATA[<p>Thanks for this&#8230; exactly what I needed.</p>
<p>You absolute legend</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-129012</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Mon, 29 Oct 2007 11:54:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-129012</guid>
		<description>Olle,

Thanks for the info!

Bernie,

You need to send in &lt;code&gt;background-image&lt;/code&gt; to the function, like in CSS. Alternatively, you can send in just &lt;code&gt;background&lt;/code&gt;

Andrei,

Thank you!
1. It's a good suggestion, but it was a deliberate choice to have it return the unit as well, in case there are more than one unit in use.
2. The problem is that what is returned is the default value in the web browser, which can differ quite a lot between different web browsers.</description>
		<content:encoded><![CDATA[<p>Olle,</p>
<p>Thanks for the info!</p>
<p>Bernie,</p>
<p>You need to send in <code>background-image</code> to the function, like in <acronym title="Cascading Style Sheets">CSS</acronym>. Alternatively, you can send in just <code>background</code></p>
<p>Andrei,</p>
<p>Thank you!<br />
1. It&#8217;s a good suggestion, but it was a deliberate choice to have it return the unit as well, in case there are more than one unit in use.<br />
2. The problem is that what is returned is the default value in the web browser, which can differ quite a lot between different web browsers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bereczki Andrei</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-128956</link>
		<dc:creator>Bereczki Andrei</dc:creator>
		<pubDate>Mon, 29 Oct 2007 09:05:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-128956</guid>
		<description>o, forgot to mention, if i set the color property in css, the border color changes to that color, even if not set ... annoying</description>
		<content:encoded><![CDATA[<p>o, forgot to mention, if i set the color property in <acronym title="Cascading Style Sheets">CSS</acronym>, the border color changes to that color, even if not set &#8230; annoying</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bereczki Andrei</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-128952</link>
		<dc:creator>Bereczki Andrei</dc:creator>
		<pubDate>Mon, 29 Oct 2007 09:03:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-128952</guid>
		<description>Hi, nice script, i was using something similar but this seems more browser friendly. I have a suggestion and 1 bug for you to fix (if you want of course):

1. Stripping away the 'px' from the return values would be nice to be able to use it in mathematical operation
i did it the following way:

if(strValue.indexOf("px") != -1){ //stripping away 'px'
strValue = parseInt( strValue.slice(0, strValue.indexOf("px")) );
}
return strValue;

2. There seems to be a bug with getting the border values. Even if the border is not set in css, i still get a 0px (medium in IE) and #000000 color for that border ... is this normal?

Have a great day! :-)</description>
		<content:encoded><![CDATA[<p>Hi, nice script, i was using something similar but this seems more browser friendly. I have a suggestion and 1 bug for you to fix (if you want of course):</p>
<p>1. Stripping away the &#8216;px&#8217; from the return values would be nice to be able to use it in mathematical operation<br />
i did it the following way:</p>
<p>if(strValue.indexOf(&#8221;px&#8221;) != -1){ //stripping away &#8216;px&#8217;<br />
strValue = parseInt( strValue.slice(0, strValue.indexOf(&#8221;px&#8221;)) );<br />
}<br />
return strValue;</p>
<p>2. There seems to be a bug with getting the border values. Even if the border is not set in <acronym title="Cascading Style Sheets">CSS</acronym>, i still get a 0px (medium in <acronym title="Internet Explorer">IE</acronym>) and #000000 color for that border &#8230; is this normal?</p>
<p>Have a great day! <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: elektronaut &#187; Blog Archive &#187; Getting computed styles in Javascript</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-98857</link>
		<dc:creator>elektronaut &#187; Blog Archive &#187; Getting computed styles in Javascript</dc:creator>
		<pubDate>Thu, 06 Sep 2007 00:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-98857</guid>
		<description>[...] computed styles in Javascript Robert Nyman has written a useful blog entry on this, you might want to read it as well. The getStyle() function is based on his, with one [...]</description>
		<content:encoded><![CDATA[<p>[...] computed styles in Javascript Robert Nyman has written a useful blog entry on this, you might want to read it as well. The getStyle() function is based on his, with one [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernie</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-93169</link>
		<dc:creator>Bernie</dc:creator>
		<pubDate>Mon, 20 Aug 2007 15:28:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-93169</guid>
		<description>This function doesn't work in Firefox with "backgroundImage".</description>
		<content:encoded><![CDATA[<p>This function doesn&#8217;t work in Firefox with &#8220;backgroundImage&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olle Lundberg</title>
		<link>http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-82846</link>
		<dc:creator>Olle Lundberg</dc:creator>
		<pubDate>Tue, 17 Jul 2007 19:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/#comment-82846</guid>
		<description>Webkit has a bug in the way it handles the string passed to getPropertyValue() according to the spec the string passed, is case insenstive. I.e width==Width.

I have created at test case and  &lt;a href="http://bugs.webkit.org/show_bug.cgi?id=14645" title="http://bugs.webkit.org/show_bug.cgi?id=14645" rel="nofollow"&gt;reported&lt;/a&gt; it to webkit.

A workaround for now is making the strCssRule lowercase.

&lt;code&gt;
function getStyle(oElm, strCssRule){
	var strValue = "";
	strCssRule=strCssRule.toLowerCase();
	if(document.defaultView &#38;&#38; document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Webkit has a bug in the way it handles the string passed to getPropertyValue() according to the spec the string passed, is case insenstive. I.e width==Width.</p>
<p>I have created at test case and  <a href="http://bugs.webkit.org/show_bug.cgi?id=14645" title="http://bugs.webkit.org/show_bug.cgi?id=14645" rel="nofollow">reported</a> it to webkit.</p>
<p>A workaround for now is making the strCssRule lowercase.</p>
<p><code><br />
function getStyle(oElm, strCssRule){<br />
	var strValue = "";<br />
	strCssRule=strCssRule.toLowerCase();<br />
	if(document.defaultView &amp;&amp; document.defaultView.getComputedStyle){<br />
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);<br />
	}<br />
	else if(oElm.currentStyle){<br />
		strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){<br />
			return p1.toUpperCase();<br />
		});<br />
		strValue = oElm.currentStyle[strCssRule];<br />
	}<br />
	return strValue;<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
