<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dev.enekoalonso.com &#187; browser</title>
	<atom:link href="http://dev.enekoalonso.com/tag/browser/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.enekoalonso.com</link>
	<description>having fun with code</description>
	<lastBuildDate>Sat, 31 Jul 2010 05:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Detecting when CSS gets loaded by the browser with Mootools and Asset.css</title>
		<link>http://dev.enekoalonso.com/2010/01/27/detecting-when-css-gets-loaded-by-the-browser-with-mootools-and-asset-css/</link>
		<comments>http://dev.enekoalonso.com/2010/01/27/detecting-when-css-gets-loaded-by-the-browser-with-mootools-and-asset-css/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:20:22 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[asset]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=416</guid>
		<description><![CDATA[Asset.css claims to have an onload event in Mootools documentation, but sadly, not all browsers support this feature. Even worse, browsers like Chrome seem to support the event, but never fire it. After some research and testing at work, we have come up with a solution that overrides Asset.css to detect when CSS gets loaded [...]]]></description>
			<content:encoded><![CDATA[<p>Asset.css claims to have an <strong>onload</strong> event in <a href="http://mootools.net/docs/more/Utilities/Assets#Asset:css">Mootools documentation</a>, but sadly, not all browsers support this feature. Even worse, browsers like Chrome seem to support the event, but never fire it.</p>
<p>After some research and testing at work, we have come up with a solution that overrides Asset.css to detect when CSS gets loaded by the browser using the onload event in those browsers that support it (Internet Explorer and Opera) and doing polling in those that do not (Chrome, Safari and Firefox). Here is the code:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// Add callback support to Asset.css for all browsers</span></div>
</li>
<li class="li1">
<div class="de1">Asset.<span class="me1">css</span> = <span class="kw2">function</span><span class="br0">&#40;</span>source, <span class="kw3">onLoad</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> link = <span class="kw2">new</span> Element<span class="br0">&#40;</span><span class="st0">&#39;link&#39;</span>, <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; rel: <span class="st0">&#39;stylesheet&#39;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; media: <span class="st0">&#39;screen&#39;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; type: <span class="st0">&#39;text/css&#39;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; href: source</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="st0">&quot;onload&quot;</span> <span class="kw1">in</span> link<span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span>Browser.<span class="me1">Engines</span>.<span class="me1">webkit</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">onLoad</span><span class="br0">&#41;</span> link.<span class="kw3">onload</span> = <span class="kw3">onLoad</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">try</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; link.<span class="me1">sheet</span>.<span class="me1">cssRules</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; setTimeout<span class="br0">&#40;</span>arguments.<span class="me1">callee</span>, <span class="nu0">100</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">onLoad</span><span class="br0">&#41;</span> <span class="kw3">onLoad</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; link.<span class="me1">inject</span><span class="br0">&#40;</span>document.<span class="me1">head</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> link;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Load some CSS and show an alert when done</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> mycss = <span class="kw2">new</span> Asset.<span class="me1">css</span><span class="br0">&#40;</span><span class="st0">&#39;http://example.com/style.css&#39;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&#39;CSS loaded!&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Unload the css</span></div>
</li>
<li class="li1">
<div class="de1">mycss.<span class="me1">destroy</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Enjoy!</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>June 30, 2009 -- <a href="http://dev.enekoalonso.com/2009/06/30/iphone-3-0-geolocation-with-javascript/" title="iPhone 3.0 geolocation with Javascript">iPhone 3.0 geolocation with Javascript</a> (1)</li><li>March 1, 2009 -- <a href="http://dev.enekoalonso.com/2009/03/01/safari-4-rocks/" title="Safari 4 rocks">Safari 4 rocks</a> (1)</li><li>June 8, 2010 -- <a href="http://dev.enekoalonso.com/2010/06/08/change-in-websockets-handshake-protocol/" title="Change in WebSockets handshake protocol">Change in WebSockets handshake protocol</a> (0)</li><li>April 28, 2010 -- <a href="http://dev.enekoalonso.com/2010/04/28/mooml-1-2-3-bye-bye-with/" title="Mooml 1.2.3 &#8211; Bye, bye, with()">Mooml 1.2.3 &#8211; Bye, bye, with()</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/01/27/detecting-when-css-gets-loaded-by-the-browser-with-mootools-and-asset-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Safari 4 rocks</title>
		<link>http://dev.enekoalonso.com/2009/03/01/safari-4-rocks/</link>
		<comments>http://dev.enekoalonso.com/2009/03/01/safari-4-rocks/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 15:48:20 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=286</guid>
		<description><![CDATA[I&#8217;ve been using Safari both at home and work since last Thursday when I first knew it had been released and it looks very fast and solid. They have finally added some standard keyboard shortcuts, like Ctrl+Tab and now you can restore your previous session (all pages open) the next time you open the browser [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Safari both at home and work since last Thursday when I first knew it had been released and it looks very fast and solid. They have finally added some standard keyboard shortcuts, like Ctrl+Tab and now you can restore your previous session (all pages open) the next time you open the browser (although not automatically like Firefox).</p>
<p>It looks very good for web development too, since it has the Javascript console integrated and you can do direct changes on the DOM and the CSS to preview how it would look. But I think Firebug is still ahead and I&#8217;m very used to it, so I&#8217;m not ready to completely stop using Firefox.</p>
<p>I have nothing against Firefox, which has been my favorite browser for years, but the fact that it is very, very slow. I&#8217;ll say today is the slowest browser out there. Or at least it looks like that sometimes. The only extension I have is Firebug. I&#8217;ve tried removing the cache, the history, etc. with no luck.</p>
<p>So yeah, so far I&#8217;m very happy with Safari 4.</p>
<p><img class="aligncenter size-medium wp-image-287" title="Safari 4" src="http://dev.enekoalonso.com/wp-content/uploads/2009/03/picture-161-417x300.png" alt="Safari 4" width="417" height="300" /></p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 27, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/27/detecting-when-css-gets-loaded-by-the-browser-with-mootools-and-asset-css/" title="Detecting when CSS gets loaded by the browser with Mootools and Asset.css">Detecting when CSS gets loaded by the browser with Mootools and Asset.css</a> (0)</li><li>July 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/07/30/titanium-developer-love-and-hate/" title="Titanium Developer: love and hate">Titanium Developer: love and hate</a> (2)</li><li>June 30, 2009 -- <a href="http://dev.enekoalonso.com/2009/06/30/iphone-3-0-geolocation-with-javascript/" title="iPhone 3.0 geolocation with Javascript">iPhone 3.0 geolocation with Javascript</a> (1)</li><li>December 29, 2008 -- <a href="http://dev.enekoalonso.com/2008/12/29/modifying-the-url-hash-without-affecting-the-browser-history/" title="Modifying the URL Hash without affecting the browser history">Modifying the URL Hash without affecting the browser history</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2009/03/01/safari-4-rocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Modifying the URL Hash without affecting the browser history</title>
		<link>http://dev.enekoalonso.com/2008/12/29/modifying-the-url-hash-without-affecting-the-browser-history/</link>
		<comments>http://dev.enekoalonso.com/2008/12/29/modifying-the-url-hash-without-affecting-the-browser-history/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 23:51:15 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[modify]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=223</guid>
		<description><![CDATA[Although this is not very common, some times you would like to modify the URL hash (this is the value after the # on the URL) without affecting the browser history. Let&#8217;s say you have multiple sets of tabs on your page or simply that your hash is going to change very often. But still [...]]]></description>
			<content:encoded><![CDATA[<p>Although this is not very common, some times you would like to modify the URL hash (this is the value after the # on the URL) without affecting the browser history. Let&#8217;s say you have multiple sets of tabs on your page or simply that your hash is going to change very often. But still want the user to be able to grab a permanent link to that page configuration.</p>
<p>The trick is to use the replace function, instead of directly assigning the value.</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// Direct assignment will add a new step to the history on browsers like Firefox 3</span></div>
</li>
<li class="li1">
<div class="de1">window.<span class="me1">location</span>.<span class="me1">hash</span> = newHash;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Using the replace function changes the hash without affecting the browser history.</span></div>
</li>
<li class="li1">
<div class="de1">window.<span class="me1">location</span>.<span class="me1">replace</span><span class="br0">&#40;</span>window.<span class="me1">location</span>.<span class="me1">href</span>.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&#39;#&#39;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> + <span class="st0">&#39;#&#39;</span> +newHash<span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Nice.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>July 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/07/30/titanium-developer-love-and-hate/" title="Titanium Developer: love and hate">Titanium Developer: love and hate</a> (2)</li><li>July 20, 2010 -- <a href="http://dev.enekoalonso.com/2010/07/20/little-tricks-string-padding-in-javascript/" title="Little tricks: string padding in Javascript">Little tricks: string padding in Javascript</a> (2)</li><li>July 1, 2010 -- <a href="http://dev.enekoalonso.com/2010/07/01/little-tricks-editing-strings-by-index-in-javascript-and-python/" title="Little tricks: editing strings by index in Javascript and Python">Little tricks: editing strings by index in Javascript and Python</a> (1)</li><li>May 22, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/22/more-websockets-now-with-python/" title="More WebSockets, now with Python!">More WebSockets, now with Python!</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2008/12/29/modifying-the-url-hash-without-affecting-the-browser-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
