<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CSS Computed Style</title>
	<atom:link href="http://blog.stchur.com/2006/06/21/css-computed-style/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stchur.com/2006/06/21/css-computed-style/</link>
	<description>If you don&#039;t expect too much from me, you might not be let down.</description>
	<lastBuildDate>Thu, 26 Jan 2012 08:23:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Dynamic Resize by Background Image &#124; while($alive) LiveAndLearn();</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-80296</link>
		<dc:creator>Dynamic Resize by Background Image &#124; while($alive) LiveAndLearn();</dc:creator>
		<pubDate>Fri, 10 Sep 2010 16:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-80296</guid>
		<description>[...] https://developer.mozilla.org/en/DOM/window.getComputedStyle  http://blog.stchur.com/2006/06/21/css-computed-style  http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx  [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle" rel="nofollow">https://developer.mozilla.org/en/DOM/window.getComputedStyle</a>  <a href="http://blog.stchur.com/2006/06/21/css-computed-style" rel="nofollow">http://blog.stchur.com/2006/06/21/css-computed-style</a>  <a href="http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx" rel="nofollow">http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx</a>  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BLARGH!! for the people &#187; Get Computed Style in JavaScript</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-44806</link>
		<dc:creator>BLARGH!! for the people &#187; Get Computed Style in JavaScript</dc:creator>
		<pubDate>Mon, 05 Apr 2010 10:26:21 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-44806</guid>
		<description>[...] The computed style of an element incorporates external CSS (via stylesheets), inline styles and styles prescribed via JavaScript. It&#8217;s most commonly used to get the default style of an element if it&#8217;s not specifically assigned via styles, i.e. the default style that the browser gives an element. It&#8217;s a very undocumented part of JavaScript engines, and, of course, there are multiple implementations. For more details, read this blog post. [...]</description>
		<content:encoded><![CDATA[<p>[...] The computed style of an element incorporates external CSS (via stylesheets), inline styles and styles prescribed via JavaScript. It&#039;s most commonly used to get the default style of an element if it&#039;s not specifically assigned via styles, i.e. the default style that the browser gives an element. It&#039;s a very undocumented part of JavaScript engines, and, of course, there are multiple implementations. For more details, read this blog post. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-11416</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 15 Mar 2009 17:30:39 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-11416</guid>
		<description>I had a similar problem the other day requiring the computed style in px not the currentStyle or style value The following function seems to correctly convert the style to px and ems and also handles styles in % and child elements where the parent is in % but the child is set to &quot;auto&quot;.

http://www.strictly-software.com/CSSStyleObject.asp</description>
		<content:encoded><![CDATA[<p>I had a similar problem the other day requiring the computed style in px not the currentStyle or style value The following function seems to correctly convert the style to px and ems and also handles styles in % and child elements where the parent is in % but the child is set to &#034;auto&#034;.</p>
<p><a href="http://www.strictly-software.com/CSSStyleObject.asp" rel="nofollow">http://www.strictly-software.com/CSSStyleObject.asp</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dynamic Background Image &#171; My Vietnam</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-10153</link>
		<dc:creator>Dynamic Background Image &#171; My Vietnam</dc:creator>
		<pubDate>Sun, 08 Feb 2009 11:09:16 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-10153</guid>
		<description>[...] https://developer.mozilla.org/en/DOM/window.getComputedStyle  http://blog.stchur.com/2006/06/21/css-computed-style  http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx  [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle" rel="nofollow">https://developer.mozilla.org/en/DOM/window.getComputedStyle</a>  <a href="http://blog.stchur.com/2006/06/21/css-computed-style" rel="nofollow">http://blog.stchur.com/2006/06/21/css-computed-style</a>  <a href="http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx" rel="nofollow">http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx</a>  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bookmarklet to de-cache CSS and images - Version 2 &#171; Zeroed &#38; Noughted</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-8819</link>
		<dc:creator>Bookmarklet to de-cache CSS and images - Version 2 &#171; Zeroed &#38; Noughted</dc:creator>
		<pubDate>Wed, 07 Jan 2009 23:35:38 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-8819</guid>
		<description>[...] Getting the current values of styles set via CSS can be a pain. Unless they were explicitly set via JavaScript, we can only fetch them using currentStyle or getComputedStyle, complete of course with their own browser idiosyncrasies. Therefore, the first thing we need is a function to do this for us in a cross-browser fashion. I have amended a version I found on Incoherent Babble. [...]</description>
		<content:encoded><![CDATA[<p>[...] Getting the current values of styles set via CSS can be a pain. Unless they were explicitly set via JavaScript, we can only fetch them using currentStyle or getComputedStyle, complete of course with their own browser idiosyncrasies. Therefore, the first thing we need is a function to do this for us in a cross-browser fashion. I have amended a version I found on Incoherent Babble. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melody Pedzisai</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-1461</link>
		<dc:creator>Melody Pedzisai</dc:creator>
		<pubDate>Thu, 10 Jul 2008 20:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-1461</guid>
		<description>Yes you are correct. Its a lot neater to do it that way. Thanks much for your help. I am all setup now with a few tweaks on the GWT side.</description>
		<content:encoded><![CDATA[<p>Yes you are correct. Its a lot neater to do it that way. Thanks much for your help. I am all setup now with a few tweaks on the GWT side.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sstchur</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-1449</link>
		<dc:creator>sstchur</dc:creator>
		<pubDate>Wed, 09 Jul 2008 21:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-1449</guid>
		<description>Melody,

Re: the property name has to be passed as an ecmascript binding value

That is true if you use .getPropertyValue, but I have found that using [styleProperty] has worked well for me in most cases, and all browsers use the property name in camelCase (without the dash), I believe.</description>
		<content:encoded><![CDATA[<p>Melody,</p>
<p>Re: the property name has to be passed as an ecmascript binding value</p>
<p>That is true if you use .getPropertyValue, but I have found that using [styleProperty] has worked well for me in most cases, and all browsers use the property name in camelCase (without the dash), I believe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melody Pedzisai</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-1446</link>
		<dc:creator>Melody Pedzisai</dc:creator>
		<pubDate>Wed, 09 Jul 2008 16:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-1446</guid>
		<description>OK so the site is defensive I cant show you the html. You get the idea</description>
		<content:encoded><![CDATA[<p>OK so the site is defensive I cant show you the html. You get the idea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melody Pedzisai</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-1445</link>
		<dc:creator>Melody Pedzisai</dc:creator>
		<pubDate>Wed, 09 Jul 2008 16:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-1445</guid>
		<description>I noticed that the HTML is not showing so I am trying to paste it without surrounding with &lt;code&gt;&lt;/code&gt; blocks

Here:



	        
	getComputedStyle table margin bug
	
	table{margin:100px;}
	.wrapper {      
		margin: 5px;
		padding: 10px 10px 10px 10px;    
		background-color:#dfe8f6;/*#c3daf9*/
		border: 1px solid magenta; /*TODO*/  
		display: block;
		width: 1920px;width: 1920px !important;
		height: 1022px;height: 1022px !important;
    }
	
    
	function getStyle(oElm, strCssRule){
	var strValue = &quot;&quot;;
	if(document.defaultView &amp;&amp; document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, &quot;&quot;).getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

	

</description>
		<content:encoded><![CDATA[<p>I noticed that the HTML is not showing so I am trying to paste it without surrounding with <code></code> blocks</p>
<p>Here:</p>
<p>	getComputedStyle table margin bug</p>
<p>	table{margin:100px;}<br />
	.wrapper {<br />
		margin: 5px;<br />
		padding: 10px 10px 10px 10px;<br />
		background-color:#dfe8f6;/*#c3daf9*/<br />
		border: 1px solid magenta; /*TODO*/<br />
		display: block;<br />
		width: 1920px;width: 1920px !important;<br />
		height: 1022px;height: 1022px !important;<br />
    }</p>
<p>	function getStyle(oElm, strCssRule){<br />
	var strValue = &#034;&#034;;<br />
	if(document.defaultView &amp;&amp; document.defaultView.getComputedStyle){<br />
		strValue = document.defaultView.getComputedStyle(oElm, &#034;&#034;).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 />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melody Pedzisai</title>
		<link>http://blog.stchur.com/2006/06/21/css-computed-style/comment-page-1/#comment-1444</link>
		<dc:creator>Melody Pedzisai</dc:creator>
		<pubDate>Wed, 09 Jul 2008 16:13:26 +0000</pubDate>
		<guid isPermaLink="false">http://stchur.com/blog2/2006/06/21/css-computed-style/#comment-1444</guid>
		<description>Thanks sstchur.
I tried it in a watered down html page and it works just fine in IE and fireFox. I think there is a problem with the CSS styles on the element when I pass it from GWT to JavaScript using JSNI. It simply wont recognize any properties. 

Back to square one!

The one thing that I would just add that seems not too clear in your code is that in fireFox, the property name has to be passed as an ecmascript binding value ie. border-bottom, whereas in IE you have to pass the property name without the dash ie. borderBottom. So I found some code somewhere for removing the dash and making the letter after it uppercase. 

&lt;code&gt;



	        
	getComputedStyle table margin bug
	
	table{margin:100px;}
	.wrapper {      
		margin: 5px;
		padding: 10px 10px 10px 10px;    
		background-color:#dfe8f6;/*#c3daf9*/
		border: 1px solid magenta; /*TODO*/  
		display: block;
		width: 1920px;width: 1920px !important;
		height: 1022px;height: 1022px !important;
    }
	
    
	function getStyle(oElm, strCssRule){
	var strValue = &quot;&quot;;
	if(document.defaultView &amp;&amp; document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, &quot;&quot;).getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

	




  
   
            
      
      
          
      
        
             YYYYYYYYYYYYYYYY
         

Actual margin is set to 100px

var foo = document.getElementById(&#039;wrapper&#039;);
alert(&#039;Padding-Right: &#039;+ getStyle(foo, &#039;padding-right&#039;));
alert(&#039;Margin-Right: &#039;+ getStyle(foo, &#039;margin-right&#039;));



&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Thanks sstchur.<br />
I tried it in a watered down html page and it works just fine in IE and fireFox. I think there is a problem with the CSS styles on the element when I pass it from GWT to JavaScript using JSNI. It simply wont recognize any properties. </p>
<p>Back to square one!</p>
<p>The one thing that I would just add that seems not too clear in your code is that in fireFox, the property name has to be passed as an ecmascript binding value ie. border-bottom, whereas in IE you have to pass the property name without the dash ie. borderBottom. So I found some code somewhere for removing the dash and making the letter after it uppercase. </p>
<p><code></code></p>
<p>	getComputedStyle table margin bug</p>
<p>	table{margin:100px;}<br />
	.wrapper {<br />
		margin: 5px;<br />
		padding: 10px 10px 10px 10px;<br />
		background-color:#dfe8f6;/*#c3daf9*/<br />
		border: 1px solid magenta; /*TODO*/<br />
		display: block;<br />
		width: 1920px;width: 1920px !important;<br />
		height: 1022px;height: 1022px !important;<br />
    }</p>
<p>	function getStyle(oElm, strCssRule){<br />
	var strValue = "";<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 />
}</p>
<p>             YYYYYYYYYYYYYYYY</p>
<p>Actual margin is set to 100px</p>
<p>var foo = document.getElementById('wrapper');<br />
alert('Padding-Right: '+ getStyle(foo, 'padding-right'));<br />
alert('Margin-Right: '+ getStyle(foo, 'margin-right'));</p>
<p></p>
]]></content:encoded>
	</item>
</channel>
</rss>

