<?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/"
	>

<channel>
	<title>Tim Saylor</title>
	<atom:link href="http://timsaylor.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://timsaylor.com</link>
	<description>Web Developer</description>
	<pubDate>Thu, 21 Jan 2010 03:36:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing Email in Django The Easy Way</title>
		<link>http://timsaylor.com/2010/01/20/testing-email-in-django-the-easy-way/</link>
		<comments>http://timsaylor.com/2010/01/20/testing-email-in-django-the-easy-way/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:36:30 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[testing]]></category>

		<category><![CDATA[tools]]></category>

		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=213</guid>
		<description><![CDATA[Today a coworker showed me a very easy way to test django code that sends emails.  It&#8217;s straight from the documentation:
Another approach is to use a &#8220;dumb&#8221; SMTP server that receives the e-mails locally and displays them to the terminal, but does not actually send anything. Python has a built-in way to accomplish this with [...]]]></description>
			<content:encoded><![CDATA[<p>Today a coworker showed me a very easy way to test django code that sends emails.  It&#8217;s straight from the <a href="http://docs.djangoproject.com/en/dev/topics/email/#testing-e-mail-sending" target="_blank">documentation</a>:</p>
<blockquote><p>Another approach is to use a &#8220;dumb&#8221; SMTP server that receives the e-mails locally and displays them to the terminal, but does not actually send anything. Python has a built-in way to accomplish this with a single command:</p>
<div class="highlight-python">
<pre>python -m smtpd -n -c DebuggingServer localhost:1025</pre>
</div>
<p>This command will start a simple SMTP server listening on port 1025 of localhost. This server simply prints to standard output all e-mail headers and the e-mail body. You then only need to set the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/settings/#setting-EMAIL_HOST"><tt class="xref docutils literal"><span class="pre">EMAIL_HOST</span></tt></a> and <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/settings/#setting-EMAIL_PORT"><tt class="xref docutils literal"><span class="pre">EMAIL_PORT</span></tt></a> accordingly, and you are set.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2010/01/20/testing-email-in-django-the-easy-way/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Idea: Here&#8217;s the proof</title>
		<link>http://timsaylor.com/2010/01/18/idea-heres-the-proof/</link>
		<comments>http://timsaylor.com/2010/01/18/idea-heres-the-proof/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 17:32:11 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=210</guid>
		<description><![CDATA[People are always making wild claims on the internet. Herestheproof.com would give them a canonical resource for evidence of their claims. Anyone could start &#60;someclaim&#62;.herestheproof.com and list their evidence. Other people can edit the page until the evidence is optimized. Then the information is easily accessible in a debate, for reporting, etc.
There&#8217;s still some problems [...]]]></description>
			<content:encoded><![CDATA[<p>People are always making wild claims on the internet. Herestheproof.com would give them a canonical resource for evidence of their claims. Anyone could start &lt;someclaim&gt;.herestheproof.com and list their evidence. Other people can edit the page until the evidence is optimized. Then the information is easily accessible in a debate, for reporting, etc.</p>
<p>There&#8217;s still some problems with this idea. First, how do you ensure the evidence is real? With no direct debater there&#8217;s no one on point to dispute the credibility of evidence. The reader can do this themselves but that shouldn&#8217;t go on too long. There could be a wiki tag to show that a particular piece of evidence is disputed. That would create a claim page for the claim that the evidence is false.</p>
<p>Also, this is vulnerable to spam. It literally invites things like &#8220;extenze-makes-your-penis-bigger.herestheproof.com&#8221;.  I don&#8217;t know if I consider this a problem. That is a legitimate claim, and the &#8220;evidence&#8221; would be disputed if any were provided as for any other claim. There could also be totally unrelated content added as evidence for a claim. Crowdsourcing and backend behavior tracking algorithms could help solve this problem.</p>
<p>Overall, many of the problems this would have are similar to ones experienced by wikipedia, so that would be the place to look for solutions.</p>
<p>Please leave me comments with your thoughts on this idea. I&#8217;m unsure if there&#8217;s enough differentiation from existing resources for this to be worth pursuing, but I haven&#8217;t spent much time thinking this through yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2010/01/18/idea-heres-the-proof/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Idea: Book Sprints</title>
		<link>http://timsaylor.com/2010/01/11/idea-book-sprints/</link>
		<comments>http://timsaylor.com/2010/01/11/idea-book-sprints/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 00:12:06 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[idea]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=207</guid>
		<description><![CDATA[Do you have a topic you want to learn about by reading a book, but you anticipate having trouble getting through it all?  For me, a topic like this came up today, Noam Chomsky.  He&#8217;s a popular modern philosophical figure so I feel like I should know what he stands for, but I [...]]]></description>
			<content:encoded><![CDATA[<p>Do you have a topic you want to learn about by reading a book, but you anticipate having trouble getting through it all?  For me, a topic like this came up today, Noam Chomsky.  He&#8217;s a popular modern philosophical figure so I feel like I should know what he stands for, but I expect I&#8217;ll disagree with everything he says and will have a hard time getting through very much of the dense content that usually comes in philosophy books.  So I tried to think of a better way to get the information I want out of the book without getting bogged down and giving up.</p>
<p>I came up with Book Sprints.  Basically, iterate through books a chapter at a time and treat them as a choose your own adventure.  Choose your starting point, probably the first chapter, and as you go keep track of what topic you understood the least or want to learn about the most.  Then skip to another chapter that addresses that topic the best.  Many people do this already, but it could be enhanced by collaborating with other people who are reading or have read the same book.</p>
<p>The value add in this idea is to create a web site that allows people to participate in a discussion about each chapter of the book individually.  This discussion can help the reader to keep track of what they&#8217;ve learned from the book, and to enhance their understanding with input from other people who may be subject matter experts or may have just read more of the book.  The discussion can pique the reader&#8217;s curiosity about another section of the book and inspire them to keep on reading.</p>
<p>So what do you think of this idea?  Is it worth thinking out a little further, or is there not enough here to be worth anything?</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2010/01/11/idea-book-sprints/feed/</wfw:commentRss>
		</item>
		<item>
		<title>inner join</title>
		<link>http://timsaylor.com/2009/04/02/inner-join/</link>
		<comments>http://timsaylor.com/2009/04/02/inner-join/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 23:15:38 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=199</guid>
		<description><![CDATA[Today I had a sql query joining a bunch of tables that looked to be hanging.  I ran it and went to lunch, and when I got back it still wasn&#8217;t done.  So I killed all my connection threads, restarted the server, tried to find every way I could to kill any errant table locks [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had a sql query joining a bunch of tables that looked to be hanging.  I ran it and went to lunch, and when I got back it still wasn&#8217;t done.  So I killed all my connection threads, restarted the server, tried to find every way I could to kill any errant table locks that were hanging around, but nothing would make it complete.  Finally after going through the syntax again I noticed that I left off the condition joining one of the tables, so it was joining 500,000 rows * 100,000 rows and it just hadn&#8217;t finished in the hour I left it to work.</p>
<p>I was more likely to have this problem because of the joining syntax I was taught:</p>
<p><code>select *<br />
from table1, table2<br />
where table1.id = table2.id</code></p>
<p>As you add more tables the where clause gets longer, and combined with the rest of the query&#8217;s constraints it gets easy to lose track of the ones that are necessary to do the joins properly.  My boss never has this problem because he uses a different syntax:</p>
<p><code>select *<br />
from table1<br />
inner join table2 on table1.id = table2.id<br />
where ...</code></p>
<p>This way, you can easily see what constraints are joining the tables together and would know if there was something missing.  Also, this syntax is more like what you would use for left and right joins, so your queries will be more consistent.  So from now on I&#8217;m going to use this syntax to try and avoid wasting time figuring out a problem that&#8217;s so easily preventable.</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2009/04/02/inner-join/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making Things Work or Doing Them Right</title>
		<link>http://timsaylor.com/2009/03/09/making-things-work-or-doing-them-right/</link>
		<comments>http://timsaylor.com/2009/03/09/making-things-work-or-doing-them-right/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 20:37:39 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=98</guid>
		<description><![CDATA[When I&#8217;m trying to figure out how to get my CSS styles to render properly there are usually a number of possible solutions that &#8220;work&#8221;.  I sometimes have trouble deciding which one is the best: the one with the most concise CSS?  The one with the least entanglement with the HTML?  It [...]]]></description>
			<content:encoded><![CDATA[<p>When I&#8217;m trying to figure out how to get my CSS styles to render properly there are usually a number of possible solutions that &#8220;work&#8221;.  I sometimes have trouble deciding which one is the best: the one with the most concise CSS?  The one with the least entanglement with the HTML?  It can be hard to know which way is &#8220;right&#8221;.</p>
<p>While I was working on the <a href="http://timsaylor.com/portfolio/">portfolio</a> on this site, I had a problem like this.  I wanted to float the screen shot to the left so the text would wrap around it, but I had to get the container for each screenshot/description to actually encapsulate them so its external spacing would line up properly.  The usual way I knew to do it was to put another element in there that cleared the float so the container would be forced down where I want it.  However this seems hackish and entangles the display with the content more than I like, so I looked for a better way.</p>
<p>I found a page on the subject of <a href="http://www.quirksmode.org/css/clearing.html">clearing floats</a> and immediately I could see that the solution described there was the &#8220;right&#8221; way to do it.  It&#8217;s simple, unentangling, and above all it works.  This is one I&#8217;ll have to remember for next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2009/03/09/making-things-work-or-doing-them-right/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Character Sets are Important™</title>
		<link>http://timsaylor.com/2009/03/03/character-sets-are-important/</link>
		<comments>http://timsaylor.com/2009/03/03/character-sets-are-important/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 00:39:17 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=104</guid>
		<description><![CDATA[(Note: since this article is about a character that shouldn&#8217;t have been able to appear on my screen, I&#8217;ve used that character several times to demonstrate.  If you can&#8217;t see it, it&#8217;s the trademark character, an elevated TM.)
A few days ago I implemented an &#8220;email this product to your friend&#8221; feature for my new employer [...]]]></description>
			<content:encoded><![CDATA[<p>(Note: since this article is about a character that shouldn&#8217;t have been able to appear on my screen, I&#8217;ve used that character several times to demonstrate.  If you can&#8217;t see it, it&#8217;s the trademark character, an elevated TM.)</p>
<p>A few days ago I implemented an &#8220;email this product to your friend&#8221; feature for my new employer <a href="http://www.reusablebags.com">Reusable Bags</a>.  It all went smoothly until I tested it with products like &#8220;ACME Bags™ Workhorse Style 1500&#8243;.  The ™ in that name caused me endless problems, all related to one of the least known aspects of computing (at least for English speakers), character encoding.</p>
<p>I&#8217;ve read Joel Spolsky&#8217;s <a href="http://www.joelonsoftware.com/articles/Unicode.html">article on character encoding</a>, so I know just enough to identify that my problem has to do with that, but not enough to know how to fix it.  I find out that on our website, where the ™ displays fine, the charset is &#8220;ISO-8854-1&#8243; a.k.a. Latin1.  This is used without problems all over the place.  The curiosity here is that ™ <strong>is not in that charset</strong>.  Somehow Firefox translated a sequence of bits from the web page into a character that shouldn&#8217;t even exist.  I couldn&#8217;t wrap my head around that, so I kind of assumed that it was expressing it some other way I didn&#8217;t know about and kept going.  In the emails I was sending, the character was displaying as a sequence of 3 unusual characters, meaning it was being interpreted wrong.  The charset in the email was Latin1 so that was what I would expect from the browser.  Since it was 3 chars, that reinforced my idea that it was being encoded in some other unusual way (with multiple bytes) and I kept looking.</p>
<p>I tried everything I could figure to try and make some headway on this bug.  I used every English charset I could find everywhere to see if I was inputting the character in one set and interpreting it with another, but nothing worked.  I would recount everything I tried, but there was so much I don&#8217;t remember it all.  I spent probably half a day just switching charsets and retrying things.</p>
<p>Eventually we gave up on representing the character properly and just wanted to strip it out, so I threw in a &#8220;str_replace(&#8221;™&#8221;, &#8220;&#8221;, $string)&#8221;.  This didn&#8217;t work either!  I could replace anything else in the string, but not that blasted ™!  This problem was preposterous.  There&#8217;s no way PHP isn&#8217;t recognizing this character.  I wrote a testing script to verify the problem in absence of the rest of the page, and there it was recognized and replaced just fine.  So what was the difference between the two scripts?</p>
<p>The difference was the source of the text being searched.  In my testing script, I typed both the needle and the haystack.  In the real page, the haystack came out of the database.  I don&#8217;t think the database pays much attention to the character encoding, it just stores whatever sequence of bytes you enter.  So the encoding used on that string depends on who entered it.  Who did enter it?  A Windows user.  Therefore, the encoding was undoubtedly Windows-1252, which is one of the only encodings I found that includes the ™ character.  If I had been smart about it earlier I would have realized that must be the case, because someone obviously entered the character and Windows-1252 is the only encoding that contains it in a way that&#8217;s easy to enter.</p>
<p>So how do I type that character in our code files that aren&#8217;t Windows-1252?  Well I know that in that encoding, ™ is represented by the number 157.  That means I can get php to give it to me with the call &#8220;chr(157)&#8221;.  I put that into my str_replace call from earlier and it worked perfectly; detected the ™ and stripped it out no problem.  Originally I was going to berate the PHP developers for assuming the Windows-1252 charset in the chr() function but I subsequently realized that it doesn&#8217;t matter what little picture is associated with character #157 in any encoding, the binary is still the same.</p>
<p>So the lesson here is to not assume something quasi-magical is happening when two facts seem to conflict, like when I assumed the ™ was encoded in some multi-byte extension to Latin1.  It can&#8217;t be, that&#8217;s not possible.  The only common encoding in the English world that includes it is Windows-1252, so that had to be what I was seeing, despite Firefox reporting otherwise.  If I had realized and accepted that earlier I would have saved myself a lot of shotgun debugging.  Why Firefox did that is a separate question that I don&#8217;t really care enough to answer, but IE does some auto-detecting of character encodings and displays whatever it thinks will work the best.  Maybe Firefox did the same thing, ignoring the encoding specified in the document, and forgot to update the page info?  That&#8217;s all I can figure.</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2009/03/03/character-sets-are-important/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Website</title>
		<link>http://timsaylor.com/2009/02/12/new-website/</link>
		<comments>http://timsaylor.com/2009/02/12/new-website/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 01:08:18 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://timsaylor.com/?p=6</guid>
		<description><![CDATA[I decided to finally ditch my old static HTML site for this fancy new wordpress blog.  I have some experience customizing wordpress for Lively Ivy so I don&#8217;t expect to have too much trouble hammering this out to my liking.  I&#8217;ll be unifying my blogs from livejournal and blogger with this site eventually.  Ideally I [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to finally ditch my old static HTML site for this fancy new wordpress blog.  I have some experience customizing wordpress for <a title="Lively Ivy" href="http://http://www.livelyivy.com">Lively Ivy</a> so I don&#8217;t expect to have too much trouble hammering this out to my liking.  I&#8217;ll be unifying my blogs from livejournal and blogger with this site eventually.  Ideally I can migrate all the old posts to here and syndicate the new ones back to livejournal to keep up with my friends there.  I don&#8217;t know if that&#8217;s possible without too much trouble though, so who knows how it&#8217;ll end up?</p>
<p>I still have my <a href="http://timsaylor.com/misc/tim-saylor-resume.pdf">resume</a> available, and now I have  <a href="http://timsaylor.com/portfolio/">portfolio</a> as well.  </p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2009/02/12/new-website/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP best practices</title>
		<link>http://timsaylor.com/2008/07/09/php-best-practices/</link>
		<comments>http://timsaylor.com/2008/07/09/php-best-practices/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 01:16:00 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[frameworks]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://timsaylor.com/2008/07/09/php-best-practices/</guid>
		<description><![CDATA[I&#8217;m currently working for a company that uses the LAMP application stack.  They have only had one full time programmer since they started, and he&#8217;s a cowboy.  They don&#8217;t use much of a database abstraction layer, they mix their display code with their business logic, they don&#8217;t do any testing, and even worse [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working for a company that uses the LAMP application stack.  They have only had one full time programmer since they started, and he&#8217;s a cowboy.  They don&#8217;t use much of a database abstraction layer, they mix their display code with their business logic, they don&#8217;t do any testing, and even worse than not using source control at all, they <span style="font-style: italic;">sometimes</span> use source control. </p>
<p>I&#8217;m starting a new project that will be fairly large and independent from the rest of the site, so I&#8217;d like to introduce some better development practices.  I don&#8217;t know much about php frameworks and stuff, so if you have any suggestions for what I should use please post them in the comments.  The only major requirement is that it can be used along side the existing code.  So what do you suggest?</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2008/07/09/php-best-practices/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JS equivalence operators: &#34;Good enough for government work&#34;</title>
		<link>http://timsaylor.com/2008/06/30/js-equivalence-operators-good-enough-for-government-work/</link>
		<comments>http://timsaylor.com/2008/06/30/js-equivalence-operators-good-enough-for-government-work/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 21:10:00 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://timsaylor.com/2008/06/30/js-equivalence-operators-good-enough-for-government-work/</guid>
		<description><![CDATA[I was having some strange behavior with a javascript app I wrote.  It&#8217;s an image thumbnailing interface that allowed the user to zoom and drag an image around.  When it loads, the image is scaled to be either as tall or as wide as the thumbnail size, and the other dimension is larger. [...]]]></description>
			<content:encoded><![CDATA[<p>I was having some strange behavior with a javascript app I wrote.  It&#8217;s an image thumbnailing interface that allowed the user to zoom and drag an image around.  When it loads, the image is scaled to be either as tall or as wide as the thumbnail size, and the other dimension is larger.  The user can zoom in and out, but they can&#8217;t zoom it smaller than it starts so no whitespace can appear.  When a user zoomed in and then all the way out, the image would pop out of the frame a little bit and whitespace would appear at the bottom (this was an image that was as tall as the thumbnail size, I imagine the whitespace would be on the right if the image were as wide as the thumbnail size and taller).  After tracing through the javascript for a while I realized the problem; javascript considers (&#8221; == 0) to be True. </p>
<p>I have a function that repositions the image so when you zoom in/out it stays centered on the same point.  I wanted to be able to call it to reposition for a move that only had a horizontal vector, so I made it check to make sure there was a value for each of the x and y coordinates before it tried moving the image on that vector.  I passed in an empty string when I didn&#8217;t want to make a move on that vector.  The problem came in to play when I zoomed out to the max and the image&#8217;s position on the short dimension became 0.  I want to move the image to 0 on that vector, but my test for no value was catching the 0 and calling it &#8220;nothing&#8221;, just like &#8221;. </p>
<p>Once I tracked this down, the solution was simple.  Just use the &#8220;really equal, I mean it for reals&#8221; operator; a.k.a. &#8220;===&#8221;. <br />
<blockquote>if (left != &#8221; || left === 0) { do stuff; }</p></blockquote>
<p>A more appropriate way to do this might be to have a real value like &#8220;nochange&#8221; mark when I don&#8217;t want to do anything with that vector, but I did this because I didn&#8217;t want to find all the places where I used &#8221; and change them.</p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2008/06/30/js-equivalence-operators-good-enough-for-government-work/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#34;bug&#34; with onclick handlers in IE</title>
		<link>http://timsaylor.com/2008/06/25/bug-with-onclick-handlers-in-ie/</link>
		<comments>http://timsaylor.com/2008/06/25/bug-with-onclick-handlers-in-ie/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 20:07:00 +0000</pubDate>
		<dc:creator>tsaylor</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[internet]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[technology]]></category>

		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://timsaylor.com/2008/06/25/bug-with-onclick-handlers-in-ie/</guid>
		<description><![CDATA[I had an issue today with Internet Explorer.  An object with an onClick handler worked fine in Firefox and Safari, but in IE the handler only fired every other click.  In the course of debugging I discovered that if I clicked slowly, it worked on every click.  I realized that this was [...]]]></description>
			<content:encoded><![CDATA[<p>I had an issue today with Internet Explorer.  An object with an onClick handler worked fine in Firefox and Safari, but in IE the handler only fired every other click.  In the course of debugging I discovered that if I clicked slowly, it worked on every click.  I realized that this was because IE must be registering an onDblClick event instead of two onClick events.  A little testing confirmed this.  I searched to see if someone else had the same problem, and found <a href="http://codingforums.com/archive/index.php?t-45921.html">this page</a>.  User jamescover had the same issue and found a solution: use the onMouseUp event to handle clicks instead of onClick.  He also directed the focus in the onMouseDown event, but I found that part to be unnecessary in my application.  A demo of his solution can be found <a href="http://www.ekigroup.com/javascript/mozilla.html">here</a>.  I&#8217;ll reproduce the code in this post in case that page ever gets taken down:<br /><code><br />&lt;script type=&#8221;text/javascript&#8221;&gt;<br />&lt;!&#8211;</p>
<p>var x = 0;<br />function addX(){<br />document['oFrm']['num'].value = x;<br />x++;<br />}</p>
<p>var y = 0;<br />function addY(){<br />document['oFrm2']['num2'].value = y;<br />y++;<br />}</p>
<p>//&#8211;&gt;<br />&lt;/script&gt;<br />This one invokes the function &lt;b&gt;onclick&lt;/b&gt;<br />&lt;form name=&#8221;oFrm&#8221;&gt;<br />&lt;input type=&#8221;text&#8221; name=&#8221;num&#8221; size=&#8221;5&#8243; /&gt;<br />&lt;input type=&#8221;button&#8221; value=&#8221;add&#8221; onclick=&#8221;addX();&#8221; /&gt;<br />&lt;/form&gt;<br />This one focuses the text field &lt;b&gt;onmousedown&lt;/b&gt;, then invokes the function &lt;b&gt;onmouseup&lt;/b&gt;<br />&lt;form name=&#8221;oFrm2&#8243;&gt;<br />&lt;input type=&#8221;text&#8221; name=&#8221;num2&#8243; size=&#8221;5&#8243; /&gt;<br />&lt;input type=&#8221;button&#8221; value=&#8221;add&#8221; onmousedown=&#8221;this.focus();&#8221; onmouseup=&#8221;addY();&#8221; /&gt;<br />&lt;/form&gt;<br /></code></p>
]]></content:encoded>
			<wfw:commentRss>http://timsaylor.com/2008/06/25/bug-with-onclick-handlers-in-ie/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
