<?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>dudu&#039;s blog &#187; cross-browser</title>
	<atom:link href="http://eduardo.cereto.net/tag/cross-browser/feed" rel="self" type="application/rss+xml" />
	<link>http://eduardo.cereto.net</link>
	<description>Web Analytics, Javascript, Python and Rum</description>
	<lastBuildDate>Thu, 02 Feb 2012 01:26:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Event order in different browsers</title>
		<link>http://eduardo.cereto.net/event-order-in-different-browsers</link>
		<comments>http://eduardo.cereto.net/event-order-in-different-browsers#comments</comments>
		<pubDate>Thu, 30 Jul 2009 23:30:52 +0000</pubDate>
		<dc:creator>Eduardo Cereto</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[cross-browser]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://eduardo.cereto.net/?p=20</guid>
		<description><![CDATA[I had an issue today where my event had to be triggered after another event in the onload property of body. I wasn&#8217;t sure if my event would be triggered after or before so I wrote a quick code to &#8230; <a href="http://eduardo.cereto.net/event-order-in-different-browsers">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eduardo.cereto.net/event-order-in-different-browsers"></g:plusone>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I had an issue today where my event had to be triggered after another event in the onload property of body. I wasn&#8217;t sure if my event would be triggered after or before so I wrote a quick code to test it. I was pretty sure, from the very start, that the results would disappoint me.</p>
<p>Here&#8217;s the code I used to test.</p>
<pre class="javascript">&lt;html&gt;
&lt;head&gt;
 &lt;title&gt;Event Tests&lt;/title&gt;
 &lt;script&gt;
 if(window.addEventListener){
 window.addEventListener('load',function(){alert('event1')},false);
 }else if(window.attachEvent){
 window.attachEvent('onload',function(){alert('event1');})
 }
 &lt;/script&gt;
 &lt;script src='jquery-min.js'&gt;&lt;/script&gt;
 &lt;script&gt;
 $(document).ready(function(){
 alert('jq1');
 });

 if(window.addEventListener){
 window.addEventListener('load',function(){alert('event2')},false);
 }else if(window.attachEvent){
 window.attachEvent('onload',function(){alert('event2');})
 }

 $(document).ready(function(){
 alert('jq2');
 });
 &lt;/script&gt;
&lt;/head&gt;
&lt;body onload='alert("event3")'&gt;
 &lt;script&gt;
 if(window.addEventListener){
 window.addEventListener('load',function(){alert('event4')},false);
 }else if(window.attachEvent){
 window.attachEvent('onload',function(){alert('event4');})
 }
 $(document).ready(function(){
 alert('jq3');
 });
 if(window.addEventListener){
 window.addEventListener('load',function(){alert('event5')},false);
 }else if(window.attachEvent){
 window.attachEvent('onload',function(){alert('event5');})
 }
 &lt;/script&gt;
 &lt;h1&gt;Event Tests&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3>Firefox 3.5 &amp; Google Chrome</h3>
<p>Firefox and Chrome both worked as expected. The jQuery Events were triggered first as I suspected and I was starting to get happy. Here&#8217;s the order they executed.</p>
<ol>
<li>jq1</li>
<li>jq2</li>
<li>jq3</li>
<li>event1</li>
<li>event2</li>
<li>event3</li>
<li>event4</li>
<li>event5</li>
</ol>
<h3>Internet Explorer 8</h3>
<p>Here on the other hand things started to get ugly. My smile fade away while ie shouted the following:</p>
<ol>
<li>jq1</li>
<li>jq2</li>
<li>jq3</li>
<li>event3</li>
<li>event5</li>
<li>event4</li>
<li>event2</li>
<li>event1</li>
</ol>
<h3>Internet Explorer 6 &amp; 7</h3>
<p>Run while you can.</p>
<ol>
<li>jq1</li>
<li>jq2</li>
<li>jq3</li>
<li>event3</li>
<li>event2</li>
<li>event4</li>
<li>event5</li>
<li>event1</li>
</ol>
<p>I think these results are completely nonsense. I&#8217;d be glad if someone could shed some light on this behavior. At least jQuery can save you from this madness.</p>
<h3>Conclusion</h3>
<p>Do you want to control the way your events trigger cross-browser without insane hacks? Go with <strong>jQuery</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://eduardo.cereto.net/event-order-in-different-browsers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

