<?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: Check whether the browser supports RGBA (and other CSS3 values)</title>
	<atom:link href="http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/feed/" rel="self" type="application/rss+xml" />
	<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/</link>
	<description>Life at the bleeding edge (of web standards)</description>
	<lastBuildDate>Fri, 10 Feb 2012 07:25:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Xavier</title>
		<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/#comment-151</link>
		<dc:creator>Xavier</dc:creator>
		<pubDate>Sat, 18 Apr 2009 12:41:52 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=203#comment-151</guid>
		<description>This work for me :

colorSupport = (function()
{
	var
		p = document.createElement(&#039;p&#039;),
		s = { rgb:false, rgba:false, hsl:false, hsla:false };
	try { p.style.color = &#039;rgb(1,1,1)&#039; ; s.rgb = /^rgb/.test(p.style.color); } catch(e) { };
	try { p.style.color = &#039;rgba(1,1,1,0.5)&#039; ; s.rgba = /^rgba/.test(p.style.color); } catch(e) { };
	try { p.style.color = &#039;hsl(1,1,1)&#039; ; s.hsl = /^hsl/.test(p.style.color); } catch(e) { };
	try { p.style.color = &#039;hsla(1,1,1,0.5)&#039; ; s.hsla = /^hsla/.test(p.style.color); } catch(e) { };
	s.alpha = ( s.rgba &#124;&#124; s.hsla ) ? true : false ;
	p = null;
	return s ;
})()

// return:
{ rgb:false&#124;true, rgba:false&#124;true, hsl:false&#124;true, hsla:false&#124;true, alpha:false&#124;true }

// call like:
if( colorSupport.alpha ) ...
if( colorSupport.rgba ) ...</description>
		<content:encoded><![CDATA[<p>This work for me :</p>
<p>colorSupport = (function()<br />
{<br />
	var<br />
		p = document.createElement(&#8216;p&#8217;),<br />
		s = { rgb:false, rgba:false, hsl:false, hsla:false };<br />
	try { p.style.color = &#8216;rgb(1,1,1)&#8217; ; s.rgb = /^rgb/.test(p.style.color); } catch(e) { };<br />
	try { p.style.color = &#8216;rgba(1,1,1,0.5)&#8217; ; s.rgba = /^rgba/.test(p.style.color); } catch(e) { };<br />
	try { p.style.color = &#8216;hsl(1,1,1)&#8217; ; s.hsl = /^hsl/.test(p.style.color); } catch(e) { };<br />
	try { p.style.color = &#8216;hsla(1,1,1,0.5)&#8217; ; s.hsla = /^hsla/.test(p.style.color); } catch(e) { };<br />
	s.alpha = ( s.rgba || s.hsla ) ? true : false ;<br />
	p = null;<br />
	return s ;<br />
})()</p>
<p>// return:<br />
{ rgb:false|true, rgba:false|true, hsl:false|true, hsla:false|true, alpha:false|true }</p>
<p>// call like:<br />
if( colorSupport.alpha ) &#8230;<br />
if( colorSupport.rgba ) &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lea Verou</title>
		<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/#comment-118</link>
		<dc:creator>Lea Verou</dc:creator>
		<pubDate>Sat, 04 Apr 2009 16:42:43 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=203#comment-118</guid>
		<description>Hello Shakakai! Thanks for commenting.

What do you mean by &quot;I agree with you that you should be lazy about checking supported properties.&quot;?

As for saving the result of the function, if you read my &lt;strong&gt;whole&lt;/strong&gt; article, &lt;strong&gt;I do save it - just in a different way&lt;/strong&gt;, since I don&#039;t want the function to be run at all until it&#039;s actually needed. ;)</description>
		<content:encoded><![CDATA[<p>Hello Shakakai! Thanks for commenting.</p>
<p>What do you mean by &#8220;I agree with you that you should be lazy about checking supported properties.&#8221;?</p>
<p>As for saving the result of the function, if you read my <strong>whole</strong> article, <strong>I do save it &#8211; just in a different way</strong>, since I don&#8217;t want the function to be run at all until it&#8217;s actually needed. <img src='http://lea.verou.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shakakai</title>
		<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/#comment-117</link>
		<dc:creator>Shakakai</dc:creator>
		<pubDate>Sat, 04 Apr 2009 12:41:34 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=203#comment-117</guid>
		<description>I agree with you that you should be lazy about checking supported properties. However, you might want to think about saving the result of the function after its first run, and then serving that back on all subsequent calls.

Something akin to this:

var supportsRGBa = (function(){
var supported;
var check = function(){
  if( supported != null ) return supported;
//regular function here
};
return check;
})();

Haven&#039;t tested that function but it should work.</description>
		<content:encoded><![CDATA[<p>I agree with you that you should be lazy about checking supported properties. However, you might want to think about saving the result of the function after its first run, and then serving that back on all subsequent calls.</p>
<p>Something akin to this:</p>
<p>var supportsRGBa = (function(){<br />
var supported;<br />
var check = function(){<br />
  if( supported != null ) return supported;<br />
//regular function here<br />
};<br />
return check;<br />
})();</p>
<p>Haven&#8217;t tested that function but it should work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lea Verou</title>
		<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/#comment-84</link>
		<dc:creator>Lea Verou</dc:creator>
		<pubDate>Wed, 25 Mar 2009 18:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=203#comment-84</guid>
		<description>Hello kangax! I&#039;m honored to have you in my blog! :)

About your solution:
1. I agree on the createElement part, should probably change that.
2. I don&#039;t like the idea of checking rgba support (or any other feature support) from the start, although I&#039;m aware that this is the approach favored by most libraries. The reason is, that it might not be actually needed. I understand that the overhead isn&#039;t probably significant, but if you think about checking multiple features and bugs, and the list will constantly grow, it will end up being significant one day. And what will you do then? Tell the users to change all their scripts to use a function instead of a constant (since it will take lots of years to be able to assume getter support)?</description>
		<content:encoded><![CDATA[<p>Hello kangax! I&#8217;m honored to have you in my blog! <img src='http://lea.verou.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>About your solution:<br />
1. I agree on the createElement part, should probably change that.<br />
2. I don&#8217;t like the idea of checking rgba support (or any other feature support) from the start, although I&#8217;m aware that this is the approach favored by most libraries. The reason is, that it might not be actually needed. I understand that the overhead isn&#8217;t probably significant, but if you think about checking multiple features and bugs, and the list will constantly grow, it will end up being significant one day. And what will you do then? Tell the users to change all their scripts to use a function instead of a constant (since it will take lots of years to be able to assume getter support)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kangax</title>
		<link>http://lea.verou.me/2009/03/check-whether-the-browser-supports-rgba-and-other-css3-values/#comment-83</link>
		<dc:creator>kangax</dc:creator>
		<pubDate>Wed, 25 Mar 2009 18:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://leaverou.me/?p=203#comment-83</guid>
		<description>Thanks for writing this. 

I took a bit different approach - without the need to check script element&#039;s style and then having to restore it. Simply creating a dummy element (and later null&#039;ing it) seems to work just fine (and it doesn&#039;t require script element to be present in a document ;) )

I&#039;m also not sure why you need to cache the result when it can be simply stored in a boolean. That boolean is what you would use later on in the app (so the check is only executed once)


var IS_RGBA_SUPPORTED = (function(){
  var value = &#039;rgba(1,1,1,0.5)&#039;,
      el = document.createElement(&#039;p&#039;),
      result = false;
  try {
    el.style.color = value;
    result = /^rgba/.test(el.style.color);
  } catch(e) { }
  el = null;
  return result;
})();
</description>
		<content:encoded><![CDATA[<p>Thanks for writing this. </p>
<p>I took a bit different approach &#8211; without the need to check script element&#8217;s style and then having to restore it. Simply creating a dummy element (and later null&#8217;ing it) seems to work just fine (and it doesn&#8217;t require script element to be present in a document <img src='http://lea.verou.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>I&#8217;m also not sure why you need to cache the result when it can be simply stored in a boolean. That boolean is what you would use later on in the app (so the check is only executed once)</p>
<p>var IS_RGBA_SUPPORTED = (function(){<br />
  var value = &#8216;rgba(1,1,1,0.5)&#8217;,<br />
      el = document.createElement(&#8216;p&#8217;),<br />
      result = false;<br />
  try {<br />
    el.style.color = value;<br />
    result = /^rgba/.test(el.style.color);<br />
  } catch(e) { }<br />
  el = null;<br />
  return result;<br />
})();</p>
]]></content:encoded>
	</item>
</channel>
</rss>

