<?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>Robertdot, A Web Design Blog &#187; Web Development</title>
	<atom:link href="http://robertdot.org/topics/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertdot.org</link>
	<description>A web design blog for designers that develop or developers that design.</description>
	<lastBuildDate>Fri, 05 Mar 2010 15:59:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Site Specific Hacks</title>
		<link>http://robertdot.org/2009/04/08/site-specific-hacks/</link>
		<comments>http://robertdot.org/2009/04/08/site-specific-hacks/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 14:18:03 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=186</guid>
		<description><![CDATA[
 The other day, I finally got curious about the Site Specific Hacks option in the Develop menu of Safari.  It turns out that browsers do their own hacks to certain known problem sites to make them work.  Safari allows developers to turn off these hacks in the event that the developer is [...]]]></description>
			<content:encoded><![CDATA[<p>
 The other day, I finally got curious about the <samp>Site Specific Hacks</samp> option in the <samp>Develop</samp> menu of Safari.  It turns out that browsers do their own hacks to certain known problem sites to make them work.  Safari allows developers to turn off these hacks in the event that the developer is fixing a site that has hacks in Safari.
</p>
<p>
 Opera, on the other hand, has <a href="http://my.opera.com/core/blog/show.dml/3130540">a very advanced method for dealing with site specific hacks</a>.  It&#8217;s worth a read just so to know what kind of stuff goes on in the browser that most people, including developers, never think about.  They also link to how other browsers deal with the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2009/04/08/site-specific-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer 8 Released</title>
		<link>http://robertdot.org/2009/03/19/internet-explorer-8-released/</link>
		<comments>http://robertdot.org/2009/03/19/internet-explorer-8-released/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 00:07:50 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=177</guid>
		<description><![CDATA[If you didn&#8217;t already hear (and I bet you already did), Internet Explorer 8 has been released.  For several months, I&#8217;ve been using the release candidates with the Internet Explorer 7 Compatibility Mode to test sites in IE7 and IE8.  So far, IE8 seems like a pretty good release.  I haven&#8217;t had [...]]]></description>
			<content:encoded><![CDATA[<p>If you didn&#8217;t already hear (and I bet you already did), Internet Explorer 8 has been released.  For several months, I&#8217;ve been using the release candidates with the Internet Explorer 7 Compatibility Mode to test sites in IE7 and IE8.  So far, IE8 seems like a pretty good release.  I haven&#8217;t had a chance to update yet, but I&#8217;m hoping hard that things have only gotten better.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2009/03/19/internet-explorer-8-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Browsers and Form Collection</title>
		<link>http://robertdot.org/2009/02/18/browsers-and-form-collection/</link>
		<comments>http://robertdot.org/2009/02/18/browsers-and-form-collection/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:19:09 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Opera]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=175</guid>
		<description><![CDATA[
 I&#8217;ve been writing a new form hijacker.  Since this one is a pretty big deal for me, I wanted to make sure it was properly implemented.  I implemented against my interpretation of the HTML 4 specification and did a pretty good job since I&#8217;m exactly compatible with Firefox, Opera, and Internet Explorer [...]]]></description>
			<content:encoded><![CDATA[<p>
 I&#8217;ve been writing a new form hijacker.  Since this one is a pretty big deal for me, I wanted to make sure it was properly implemented.  I implemented against my interpretation of the <abbr title="HyperText Markup Language">HTML</abbr> 4 specification and did a pretty good job since I&#8217;m exactly compatible with Firefox, Opera, and Internet Explorer 8.  Safari, Internet Explorer 6, and Internet Explorer 7 seem to have some bugs.
</p>
<p>
 Safari seems to send the values of un<code>name</code>ed <code>select</code>s, despite these elements being invalid.  So, you may get a query string like <samp>text1=test&amp;=selval</samp> if your <code>select</code> that contained an <code>option="selval"</code> doesn&#8217;t have a <code>name</code>.
</p>
<p>
 Internet Explorer 6 and 7 both mishandle <code>button</code>s.  Internet Explorer 6 sends all <code>buttons</code> with <code>name</code> attributes set, even though it should only send the <code>button</code> if it was clicked.  Internet Explorer 7 doesn&#8217;t send unclicked <code>buttons</code>, but any time Internet Explorer 6 or 7 sends a <code>button</code> it sends the <code>button</code>&#8217;s <code>innerHTML</code> instead of the value.
</p>
<p>
 So, given the deficiencies above, here&#8217;s how to compensate.  If you&#8217;re using PHP, you don&#8217;t need to worry about Safari sending <code>name</code>less <code>select</code>s as PHP seems to ignore them (or at least in <code>parse_str</code>).  If you plan to use <code>button</code>s, never give them names or values.  Use <code>radio</code> controls if you have to do conditional actions based on what the user clicks.
</p>
<p>
 I still have some other testing to do, but these findings should help you cover your bases if you&#8217;re working with forms.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2009/02/18/browsers-and-form-collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yahoo! Updates Graded Browser Support</title>
		<link>http://robertdot.org/2009/01/29/yahoo-updates-graded-browser-support/</link>
		<comments>http://robertdot.org/2009/01/29/yahoo-updates-graded-browser-support/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 16:22:54 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Browser Support]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://robertdot.org/?p=173</guid>
		<description><![CDATA[
 Yahoo! updated it&#8217;s Graded Browser Support yesterday.  The changes involved dropping support for non-Safari browsers on Mac OS X 10.4 and non-Internet Explorer browsers on Windows 2000.  Support for Internet Explorer 8 was added for Windows XP and Windows Vista.


 This has given clout to support Internet Explorer 8 (which is in [...]]]></description>
			<content:encoded><![CDATA[<p>
 Yahoo! updated it&#8217;s <a href="http://yuiblog.com/blog/2009/01/28/gbs-update-20090128/">Graded Browser Support</a> yesterday.  The changes involved dropping support for non-Safari browsers on Mac OS X 10.4 and non-Internet Explorer browsers on Windows 2000.  Support for Internet Explorer 8 was added for Windows XP and Windows Vista.
</p>
<p>
 This has given clout to support Internet Explorer 8 (which is in Release Candidate version now) in addition to versions 6 and 7.  Here&#8217;s hoping Microsoft forces Internet Explorer 8 upgrades now that version targeting has been implemented.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2009/01/29/yahoo-updates-graded-browser-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Location Awareness to Your Site</title>
		<link>http://robertdot.org/2009/01/09/adding-location-awareness-to-your-site/</link>
		<comments>http://robertdot.org/2009/01/09/adding-location-awareness-to-your-site/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:46:52 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Fire Eagle]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Location Services]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Yahoo Weather]]></category>

		<guid isPermaLink="false">http://robertdot-org.robertb.org/?p=18</guid>
		<description><![CDATA[
 I recently launched a new personal site.  I wanted to integrate some level of location awareness to it.  My initial design sketches called for the weather information and a position on a map of my last known location.


 Initially, I was using a program on my iPhone called Loopt.  Loopt is like Twitter with [...]]]></description>
			<content:encoded><![CDATA[<p>
 I recently launched a new personal site.  I wanted to integrate some level of location awareness to it.  My initial design sketches called for the weather information and a position on a map of my last known location.
</p>
<p>
 Initially, I was using a program on my iPhone called Loopt.  Loopt is like Twitter with location.  That involved jumping through hoops, as Loopt&#8217;s RSS feed only shows the GPS position of the last post.  Not only would I have to post a message every time I got somewhere, I&#8217;d have to reverse geocode my position to grab the zip code to send to get the weather information.  I achieved this through JavaScript with the Google Maps API.  This worked until I found out about <a href="http://fireeagle.yahoo.net/">Fire Eagle</a>.
</p>
<p>
 All Fire Eagle does is log your location.  Luckily, Fire Eagle has an <abbr title="Application Programming Interface">API</abbr>.  <a href="http://www.eaglefeed.me">Eagle Feed</a> turns your location into a publicly accessible <abbr title="Really Simple Syndication">RSS</abbr> feed.  So, getting your location is as easy as parsing an RSS feed.  By setting the read level of Eagle Feed to <samp>my zip code</samp>, the <code>title</code> of the single <code>item</code> in the RSS feed reports my city, state, and zip (e.g. <samp>Birmingham, AL 35223</samp>), and my GPS coordinates are also in the feed.
</p>
<p>
 You can update Fire Eagle by manually by entering your location on the site.  However, there are mobile applications, such as Active Eagle on the iPhone, that use the <abbr title="Global Positioning Satellite">GPS</abbr> functionality of your device to update Fire Eagle.  In Active Eagle, I simply tap &#8220;Update Fire Eagle&#8221; to update my location, and my Eagle Feed.
</p>
<p>
 Once you can get your feed there are plenty of cool things you can do.
</p>
<p>
 I wrote a simple <abbr title="PHP Hypertext Preprocessor">PHP</abbr> script to open my feed (or pull it from a cached file), grab the human-readable location from the <code>title</code> and parse out the zip code and my GPS position.
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$out</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;title&gt;(.*?)&lt;\/title&gt;/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$out</span><span style="color: #339933;">,</span> <span style="color: #000088;">$loc_matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$human_loc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$loc_matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\d{5}/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$human_loc</span><span style="color: #339933;">,</span> <span style="color: #000088;">$loc_matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$human_zip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$loc_matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;abbr class=&quot;latitude&quot;.*?&gt;(.*?)&lt;\/abbr&gt;/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$out</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lat</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loc_lat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lat</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;abbr class=&quot;longitude&quot;.*?&gt;(.*?)&lt;\/abbr&gt;/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$out</span><span style="color: #339933;">,</span> <span style="color: #000088;">$long</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loc_long</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$long</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
 I then pass my zip code to <a href="http://developer.yahoo.com/weather/">Yahoo&#8217;s weather feeds</a> to get weather data.  I also pass my GPS position to <a href="http://code.google.com/apis/maps/documentation/staticmaps/">Google Maps Static API</a> to get a map of where I am.
</p>
<p>
 Another idea would be to show Flickr photos in your area via the <a href="http://www.flickr.com/services/api/">Flickr API</a>.  I&#8217;m sure there are tons of other things that would be fun or useful.  Come up with some more ideas and make some cool stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2009/01/09/adding-location-awareness-to-your-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forms With Elements With Form Attribute Names</title>
		<link>http://robertdot.org/2008/09/23/forms-with-elements-with-form-attribute-names/</link>
		<comments>http://robertdot.org/2008/09/23/forms-with-elements-with-form-attribute-names/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 18:07:30 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://robertdot.org/2009/01/15/forms-with-elements-with-form-attribute-names/</guid>
		<description><![CDATA[
 I commonly create a form element that dictates the action I want the server to perform, like &#60;input type="hidden" name="action" value="save"&#62;.  This allows me to have a switch to determine what to do with the data in any situation instead of posting and getting to multiple places.  I found a bug in [...]]]></description>
			<content:encoded><![CDATA[<p>
 I commonly create a form element that dictates the action I want the server to perform, like <code>&lt;input type="hidden" name="action" value="save"&gt;</code>.  This allows me to have a <code>switch</code> to determine what to do with the data in any situation instead of posting and getting to multiple places.  I found a bug in Internet Explorer 7&#8217;s JavaScript today that introduces a problem with my naming scheme.
</p>
<p>
 When doing <abbr name="Asynchronous JavaScript and XML">Ajax</abbr>, I often use <code>form.getAttribute('action')</code> to get the location to send the request to.  This allows me to keep my code more portable.  However, in Internet Explorer 7 (or IE7 for short), if there is also a form element with <code>name="action"</code>, IE7 returns the <code>input</code> object instead of the value of the attribute as though I typed <code>formname.action</code> or, in long hand, <code>document.forms['formname'].elements['action']</code>.
</p>
<p>
 To my knowledge, there is no work around other than changing the <code>name</code> of the element.  So, I&#8217;ll be using <code>name="faction"</code> from now on.  That&#8217;s short for &#8220;form action&#8221; but &#8220;faction&#8221; itself is fairly apt given IE&#8217;s behavior is different from all other browsers, making it a faction.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2008/09/23/forms-with-elements-with-form-attribute-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL FIND_IN_SET</title>
		<link>http://robertdot.org/2008/07/31/mysql-find_in_set/</link>
		<comments>http://robertdot.org/2008/07/31/mysql-find_in_set/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 20:50:32 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://robertdot.org/2008/07/31/mysql-find_in_set/</guid>
		<description><![CDATA[
 I always forget this mySQL function, so I figured I should make note of it somewhere.  It&#8217;s called FIND_IN_SET.  You specify a variable and a list of possible matches and it returns the position of the string in the list.  It&#8217;s very helpful for sorting things in a defined list provided [...]]]></description>
			<content:encoded><![CDATA[<p>
 I always forget this mySQL function, so I figured I should make note of it somewhere.  It&#8217;s called <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set">FIND_IN_SET</a>.  You specify a variable and a list of possible matches and it returns the position of the string in the list.  It&#8217;s very helpful for sorting things in a defined list provided by the client.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2008/07/31/mysql-find_in_set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer Version Targeting Finally Makes Sense</title>
		<link>http://robertdot.org/2008/03/04/internet-explorer-version-targeting-finally-makes-sense/</link>
		<comments>http://robertdot.org/2008/03/04/internet-explorer-version-targeting-finally-makes-sense/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 10:47:11 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Version Targeting]]></category>

		<guid isPermaLink="false">http://robertdot.org/2008/03/04/internet-explorer-version-targeting-finally-makes-sense/</guid>
		<description><![CDATA[
 I kept mum about Internet Explorer 8&#8217;s version targeting to see how things played out.  It looks like Microsoft did the right thing for real web developers.


 Version targeting allows the web developer to pick which version of Internet Explorer&#8217;s rendering engine he or she would like to use.  This is great [...]]]></description>
			<content:encoded><![CDATA[<p>
 I kept mum about Internet Explorer 8&#8217;s version targeting to see how things played out.  It looks like Microsoft did the right thing for real web developers.
</p>
<p>
 Version targeting allows the web developer to pick which version of Internet Explorer&#8217;s rendering engine he or she would like to use.  This is great for big sites (like banks) because they can forever have a site that works in buggy Internet Explorer 6.  No more freak outs when Internet Explorer updates like there were with the update to version 7.  The problem wasn&#8217;t that they were introducing a proprietary header / meta tag.  The problem was that all future versions of Internet Explorer would <a href="http://alistapart.com/articles/beyonddoctype">render like version 7</a> <strong>unless the developer opted in for the newest rendering mode</strong>.  That&#8217;s right.  A large majority of people would be forever designing with Internet Explorer 7!
</p>
<p>
 The solution several web celebs they would adopt would be to set the version to <code>edge</code> to always get the latest version in an attempt to tell Microsoft that good developers don&#8217;t want to use it.  The problem is that developers had to use it to not use it.
</p>
<p>
 Fortunately, Microsoft came to their senses and <a href="http://blogs.msdn.com/ie/archive/2008/03/03/microsoft-s-interoperability-principles-and-ie8.aspx">announced</a> they would keep version targeting but have the default behavior use the latest rendering engine.  The claim is that they are trying to support the new <a href="http://www.microsoft.com/presspass/presskits/interoperability/default.mspx">Interoperability Principles</a> published in February.  No doubt part of the problem was the overwhelming response against defaulting to version 7 from the web standards community.  Either way, I&#8217;m glad Microsoft decided not to pander to the people causing the problem.
</p>
<p>
 Everyone is happy now that Internet Explorer 8 will really pass Acid 2.
</p>
<ol>
<li><a href="http://www.zeldman.com/2008/03/04/microsoft-reverses-version-targeting-default/">Jeffery Zeldman&#8217;s Post</a></li>
<li><a href="http://lachy.id.au/log/2008/03/victory">Lachlan Hunt&#8217;s Post</a></li>
<li><a href="http://www.456bereastreet.com/archive/200803/surprise_of_the_year_ie8_will_use_standards_mode_by_default/">Roger Johansson&#8217;s Post</a>
<li><a href="http://ln.hixie.ch/?start=1204593554&#038;count=1">Hixie&#8217;s Blurb</a></li>
<li><a href="http://www.webstandards.org/2008/03/03/microsoft-rethinks-ie8s-default-behavior/">Web Standard Project&#8217;s Post</a></li>
<li>And it even made it to <a href="http://slashdot.org/article.pl?sid=08/03/04/0114203">Slashdot</a></li>
</ol>
<p>
 I am thankful I don&#8217;t have to add (in addition to conditional comments) more Microsoft related junk to the <code>head</code> of my boilerplate.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2008/03/04/internet-explorer-version-targeting-finally-makes-sense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Element Swapping with Unobtrusive JavaScript</title>
		<link>http://robertdot.org/2008/02/11/element-swapping-with-unobtrusive-javascript/</link>
		<comments>http://robertdot.org/2008/02/11/element-swapping-with-unobtrusive-javascript/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 16:45:25 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://robertdot.org/2008/02/11/element-swapping-with-unobtrusive-javascript/</guid>
		<description><![CDATA[
 There may come a time when you need to show different content on one page based on a user-selected option.  Here&#8217;s a quick tutorial.


 The first step is to set up your content properly.  In this example, I&#8217;ll use a select to swap between two form elements, though the basic premise can [...]]]></description>
			<content:encoded><![CDATA[<p>
 There may come a time when you need to show different content on one page based on a user-selected option.  Here&#8217;s a quick tutorial.
</p>
<p>
 The first step is to set up your content properly.  In this example, I&#8217;ll use a <code>select</code> to swap between two form elements, though the basic premise can be applied to other design patters such as <a href="http://developer.yahoo.com/ypatterns/pattern.php?pattern=moduletabs">module tabs</a>.  Here is how the form should look.
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="htmlstrict" style="font-family:monospace;">&lt;form method=&quot;post&quot; action=&quot;post.php&quot;&gt;
 &lt;div&gt;
  &lt;label&gt;
   How Should I Reply To You?
   &lt;select name=&quot;type&quot; id=&quot;type&quot;&gt;
    &lt;option value=&quot;email&quot;&gt;E-mail&lt;/option&gt;
    &lt;option value=&quot;phone&quot;&gt;Phone&lt;/option&gt;
   &lt;/select&gt;
  &lt;/label&gt;
 &lt;/div&gt;
 &lt;div id=&quot;byemail&quot;&gt;
  &lt;label&gt;
   Enter Your Email:
   &lt;input type=&quot;text&quot; name=&quot;email&quot;&gt;
  &lt;/label&gt;
 &lt;/div&gt;
 &lt;div id=&quot;byphone&quot;&gt;
  &lt;label&gt;
   Enter Your Phone Number:
   &lt;input type=&quot;text&quot; name=&quot;phone&quot;&gt;
  &lt;/label&gt;
 &lt;/div&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>
 That is the basic setup you need.  You have something for the user to select (that has an <code>id</code> to assign, in this case, an <code>onchange</code> event), and something to swap between that have <code>id</code>s.  Now you need some JavaScript.  Comments are inline to explain things.
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* Assign the onload event to the function init. */</span>
<span style="color: #009966; font-style: italic;">/* Test which way adding events is supported. */</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* W3C method. */</span>
	window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> init<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* IE method. */</span>
	window.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onload'</span><span style="color: #339933;">,</span> init<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* Old school method. */</span>
	window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> init<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/* This is the function that runs after the page loads. */</span>
<span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* Get the select element you want the onchange to be applied to. I use the j_ prefix because sometimes errors happen when variables are named the same thing as IDs in the HTML. */</span>
	<span style="color: #003366; font-weight: bold;">var</span> j_type <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'type'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* If the element exists, we can assign the onchange event to call the swap function using the same type test we used before. */</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>j_type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>j_type.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			j_type.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'change'</span><span style="color: #339933;">,</span> swap<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>j_type.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			j_type.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onchange'</span><span style="color: #339933;">,</span> swap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			j_type.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> swap<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #009966; font-style: italic;">/* Now, we need to fire the event to get the default. */</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* The W3C method. */</span>
			<span style="color: #003366; font-weight: bold;">var</span> j_event <span style="color: #339933;">=</span> document.<span style="color: #660066;">createEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'HTMLEvents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			j_event.<span style="color: #660066;">initEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			j_type.<span style="color: #660066;">dispatchEvent</span><span style="color: #009900;">&#40;</span>j_event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createEventObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* The IE method. */</span>
			j_type.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;onchange&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/* This is the function that does the work of swapping the elements. */</span>
<span style="color: #003366; font-weight: bold;">function</span> swap<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* Get both the elements you want to swap between. */</span>
	<span style="color: #003366; font-weight: bold;">var</span> j_email <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'byemail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> j_phone <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'byphone'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* Grab the event from the W3C method or the IE method. */</span>
	<span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> e <span style="color: #339933;">||</span> window.<span style="color: #660066;">srcEvent</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* Grab the event target from the W3C method or the IE method. */</span>
	<span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> e.<span style="color: #660066;">target</span> <span style="color: #339933;">||</span> e.<span style="color: #660066;">srcElement</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* Grab the target's value */</span>
	<span style="color: #003366; font-weight: bold;">var</span> t_value <span style="color: #339933;">=</span> target.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* If both swap elements exist... */</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>j_email <span style="color: #339933;">&amp;&amp;</span> j_phone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">/* Depending on which option, hide or show the form elements. */</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>t_value <span style="color: #339933;">==</span> <span style="color: #3366CC;">'email'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			j_email.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'block'</span><span style="color: #339933;">;</span>
			j_phone.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>t_value <span style="color: #339933;">==</span> <span style="color: #3366CC;">'phone'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			j_email.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
			j_phone.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'block'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			j_email.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
			j_phone.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
 Save the script above to a file and include it in the head of your document that the form is in.  You&#8217;ll have the swapping capabilities you desire using unobtrusive JavaScript and modern <abbr title="Document Object Model">DOM</abbr> techniques.
</p>
<p>
 This was tested in Safari 3, FireFox 2, Opera 9.25, and Internet Explorer 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2008/02/11/element-swapping-with-unobtrusive-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WYMEditor HTML Textarea Loses Focus</title>
		<link>http://robertdot.org/2008/01/24/wymeditor-html-textarea-loses-focus/</link>
		<comments>http://robertdot.org/2008/01/24/wymeditor-html-textarea-loses-focus/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 18:59:21 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WYMEditor]]></category>
		<category><![CDATA[WYSIWYM]]></category>

		<guid isPermaLink="false">http://robertdot.org/2008/01/24/wymeditor-html-textarea-loses-focus/</guid>
		<description><![CDATA[
 I&#8217;ve been using the WYMEditor on a little content management system I&#8217;ve been building at work.  I was having a problem where I couldn&#8217;t edit in the HTML editor.  Every time I clicked, the HTML textarea in WYMEditor would lose focus.


 It turns out the problem was the way I used my [...]]]></description>
			<content:encoded><![CDATA[<p>
 I&#8217;ve been using the WYMEditor on a little content management system I&#8217;ve been building at work.  I was having a problem where I couldn&#8217;t edit in the <abbr title="HyperText Markup Language">HTML</abbr > editor.  Every time I clicked, the HTML textarea in WYMEditor would lose focus.
</p>
<p>
 It turns out the problem was the way I used my <code>label</code> for the textarea that turns into the WYMEditor.  There are two ways to use <code>label</code>.  One is to tie the element to a form element via <code>for="element-id"</code> where <code>element-id</code> is the <code>id</code> of the form element.  The other is to simply encapsulate the form element inside the <code>label</code>.  I was doing the latter since I had written <acronym title="Cascading Style Sheets">CSS</acronym> to display forms.
</p>
<p>
 <code>label</code>s focus the corresponding element when clicked (or when elements inside them are clicked).  If you click the element directly, the focus doesn&#8217;t change.  What I was failing to realize was that WYMEditor was putting the replacement / overlay inside the <code>label</code>.  The visual editor itself uses an <code>iframe</code>, which overrides the <code>label</code>.  The HTML Editor portion uses another <code>textarea</code>.  In FireFox, when I clicked the <code>textarea</code> to edit, the focus would shift to the hidden (and first in the code) <code>textarea</code>.
</p>
<p>
 The solution was to use the <code>for</code> method instead of the encapsulation method for WYMEditors and modify my CSS.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertdot.org/2008/01/24/wymeditor-html-textarea-loses-focus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
