<?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>JavaScript Workshop &#187; JavaScript topics</title>
	<atom:link href="http://www.javascriptworkshop.com/category/javascript-topics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptworkshop.com</link>
	<description>Helping others learn JavaScript and web development in general.</description>
	<lastBuildDate>Tue, 06 Sep 2011 11:10:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>What&#8217;s New in Drupal 7</title>
		<link>http://www.javascriptworkshop.com/2010/11/10/whats-new-in-drupal-7/</link>
		<comments>http://www.javascriptworkshop.com/2010/11/10/whats-new-in-drupal-7/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 14:04:15 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Drupal 7]]></category>
		<category><![CDATA[New in Drupal 7]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=1043</guid>
		<description><![CDATA[Let&#8217;s highlight some of the main differences in this new version of Drupal. Stories are now Articles – In an attempt to name Drupal&#8217;s core content types in ways that more closely indicate their usage, the Story content type is now Article. Articles are pieces of content that typically post blog-style to a prominent place [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s highlight some of the main differences in this new version of Drupal.</p>
<p><strong>Stories are now Articles</strong> – In an attempt to name Drupal&#8217;s core content types in ways that more closely indicate their usage, the Story content type is now Article. Articles are pieces of content that typically post blog-style to a prominent place on your site, but may be replaced, or scrolled down the page, on a regular basis as new articles are posted. </p>
<p><strong>An Administrator Role is already created at installation</strong> – Several of the changes that have been made reflect things that most users do immediately after installing Drupal. One of these is the inclusion of an Administrator role as part of the default installation profile.</p>
<p><strong>Search and Paths are enabled by default</strong> – Other things that users typically enable immediately are the Search module that allows users to search for content on the site and the Paths module which allows the creation of path aliases to content so that you can publish the link www.yoursite.com/directions instead of www.yoursite.com/node/123.<br />
<span id="more-1043"></span><br />
<strong>Basic Taxonomy Created</strong> – In previous versions, before you could have users tag their content, you had to create taxonomy vocabularies from scratch. Version 7 includes a basic tag-style vocabulary that can be assigned to content types. A tag-style vocabulary accepts comma-separated tag lists crated on the fly by authors who are entering new content. </p>
<p>This can make for kind of sloppy vocabularies as users misspell, abbreviate, or misuse terms but the tag field is ajax enabled and makes tag suggestions as the user types, which can help avoid some of these issues.</p>
<p><strong>Several Modules are gone altogether</strong>, including Throttle, Ping and Access Rules – There are some things that just need to be a part of the core program. For instance, Drupal really should throttle properly based on traffic and not on you telling it to.</p>
<p><strong>Entirely New Database Layer</strong> – Most users may never encounter the details of this change, but performance should improve and developers who do need to interact with the database layer should find it much easier to do so. A significant improvement that should come from this change is the ability for Drupal to work through its interface with a wider variety of database servers. </p>
<p><strong>SQLite Support</strong> – SQLite is a code library that provides a self-contained, server-less database platform. It is a zero-configuration platform that provides a full set of database features. </p>
<p><strong>Fields in Core</strong> – The new Fields in Core API promises to allow users to create their own custom content types that interact with the database, like the Content Construction Kite used to as an add-on module. It is still very much under construction though.</p>
<p><strong>Installation Choices</strong> – The installation routine now allows you to select from a default option that installs and activates the most common Drupal features and a basic option that installs only the core. You can then add things as you need them.</p>
<p><strong>Fewer Default Themes</strong> – Some of the default themes that shipped with previous versions were  thought to not exhibit the best practices that Drupal tries to encourage, so only Garland and Minelli remain, as well as a new Stark theme that demonstrates the Drupal markup at its most basic so that you can learn to build themes off of it.</p>
<p><strong>Menu Changes</strong> – The Navigation menus is now the Management Menu. In addition there is an Administration Menu that displays across the top of the screen with the most common admin links. Beneath that is a minimizable Content menu with links to add and find content. A new User Menu displays where the Secondary Menu used to in the default theme and offers account and logout links.</p>
<p><strong>Clean URLs are on by default</strong> – The option has been taken out of the installer and clean URLs are on by default. You should always use Clean URLs and only disable them in admin if your server has a specific problem handling them.</p>
<p><strong>Permissions Changes </strong>– When you enable a permission for the authenticated user, all other roles on the client side also get that permission and it is marked on the permissions page so that you realize the effects of the changes you are making. This reflects that fact that the authenticated user is a basic level of registered users permissions and whatever you allow them to do, you are also allowing to all other user types that require a sign in.</p>
<p><strong>Image Handling</strong> – Image handling is now available in the core program, which allows you to set up image types, like thumbnails, and also perform image effects that cropping and rotating.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2010/11/10/whats-new-in-drupal-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Magazine &#8211; JsMag</title>
		<link>http://www.javascriptworkshop.com/2009/07/27/javascript-magazine-jsmag/</link>
		<comments>http://www.javascriptworkshop.com/2009/07/27/javascript-magazine-jsmag/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:05:02 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[JavaScript magazine]]></category>
		<category><![CDATA[JsMag]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=718</guid>
		<description><![CDATA[Even with all the information on the web today, it can be difficult to find current information on JavaScript sometimes. There are a few good web magazines out there, but none truly focus solely on JavaScript related topics. I recently found an online magazine called JsMag. The magazine has some great information on topics such [...]]]></description>
			<content:encoded><![CDATA[<p>Even with all the information on the web today, it can be difficult to find current information on JavaScript sometimes. There are a few good web magazines out there, but none truly focus solely on JavaScript related topics. I recently found an online magazine called <a target = "_blank" href="http://www.jsmag.com/">JsMag</a>.</p>
<p><a target="_blank" href="http://www.jsmag.com/"><img id="jsmag" align="right" src="http://www.javascriptworkshop.com/jsmag.jpg" alt="JsMag" /></a>The magazine has some great information on topics such as Ajax, code optimization, mashups, jQuery, web application testing, event handling, EXT JS, OOP, and much more. Its unique content, focusing on mainly JavaScript related topics, keeps me continously learning new things in the JavaScript world. Talented developers write different articles each month so content is always new and comes from different perspectives.</p>
<p>The monthly issues (.pdf) are only $4.99 or you can purchase a years subscription as well. It definitely is worth the small investment if you are a JavaScript developer or interested in learning more intermediate to advanced JavaScript topics. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2009/07/27/javascript-magazine-jsmag/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bookmark your Webpage?</title>
		<link>http://www.javascriptworkshop.com/2008/10/06/bookmark-your-webpage/</link>
		<comments>http://www.javascriptworkshop.com/2008/10/06/bookmark-your-webpage/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 07:51:13 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[bookmark page]]></category>
		<category><![CDATA[web browsers]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=179</guid>
		<description><![CDATA[I&#8217;m not a fan of creating a script that only works in one browser or differently in other browser(s). I had to create a link on a website for work that made a URL their home page. This annoying task proved difficult as there wasn&#8217;t much good information online and it seems only IE allows [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not a fan of creating a script that only works in one browser or differently in other browser(s). I had to create a link on a website for work that made a URL their home page.  This annoying task proved difficult as there wasn&#8217;t much good information online and it seems only IE allows this.  The Firefox browser will only allow you to make a web page a &#8216;favorite&#8217;.</p>
<p>So I found the code to make it work on both IE and Firefox (will not work on any other browser), as well as improving its &#8216;unobtrusiveness&#8217;.  As you can see from the code, I only display the link if the browser is either Internet Explorer or Firefox otherwise the link text is blank. </p>
<p>The &#8216;Browser.Detect&#8217; object is from a script from the JavaScript guru himself, <a class="externalLink" href="http://www.quirksmode.org/">PPK</a> which detects what browser the visitor is using. Browser detection isn&#8217;t used as much today as it once was but it is still needed on some occasions.</p>
<p><span id="more-179"></span></p>
<p><img src="http://www.javascriptworkshop.com/PHPWebHost/Make_homepage/screenshot_IE.gif" /></p>
<p>Internet Explorer <br/><br />
<img src="http://www.javascriptworkshop.com/PHPWebHost/Make_homepage/screenshot_FF.gif" /></p>
<p>Firefox</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> browserBoomkark<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> link <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>BrowserDetect.<span style="color: #660066;">browser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'Explorer'</span><span style="color: #339933;">:</span>
&nbsp;
          link.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Set to Home Page'</span><span style="color: #339933;">;</span>	
          link.<span style="color: #660066;">style</span>.<span style="color: #660066;">cursor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #339933;">;</span>
          link.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">behavior</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'url(#default#homepage)'</span><span style="color: #339933;">;</span>
               <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setHomePage</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'URL'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'Firefox'</span><span style="color: #339933;">:</span> <span style="color: #006600; font-style: italic;">// only supports making page a favorite</span>
&nbsp;
           link.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Set to Favorite'</span><span style="color: #339933;">;</span>
           link.<span style="color: #660066;">style</span>.<span style="color: #660066;">cursor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #339933;">;</span>
           link.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                window.<span style="color: #660066;">sidebar</span>.<span style="color: #660066;">addPanel</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'URL'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
&nbsp;
           <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
&nbsp;
           <span style="color: #006600; font-style: italic;">// nothing is displayed for other browsers</span>
      <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Test the <a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/Make_homepage/bookmark.html"> page</a> yourself to test it out and download the <a href="http://www.javascriptworkshop.com/PHPWebHost/Make_homepage/Bookmark_page.zip">code</a> (.zip).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2008/10/06/bookmark-your-webpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DHTML in Review</title>
		<link>http://www.javascriptworkshop.com/2008/07/02/dhtml-in-review/</link>
		<comments>http://www.javascriptworkshop.com/2008/07/02/dhtml-in-review/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 01:27:28 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[date picker]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[hide and show]]></category>
		<category><![CDATA[pop-uup windows]]></category>
		<category><![CDATA[table highlighting]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=221</guid>
		<description><![CDATA[DHTML is a buzzword that came onto the scene during the version 4 browsers and tried to bring the &#8220;sexy back&#8221; to web development. Even though web standards, accessibility and unobtrusiveness were still in their infantcy, it did make the web world more aware of what you could do on the client (browser) before sending [...]]]></description>
			<content:encoded><![CDATA[<p>DHTML is a buzzword that came onto the scene during the version 4 browsers and tried to bring the &#8220;sexy back&#8221; to web development. Even though web standards, accessibility and unobtrusiveness were still in their infantcy, it did make the web world more aware of what you could do on the client (browser) before sending data to the server.</p>
<p>Even though the defintions of DHTML may never be totally accurate (the changing of the styles of HTML elements by means of JavaScript), if we can take what we have learned in the past and apply them now we can get a very thorough understanding of what JavaScript can do.</p>
<p>This <a class="externalLink" href = "http://www.javascriptworkshop.com/wp-content/uploads/pdf/E-book_DHTML_AJAX.pdf">e-book</a> (.pdf) and <a href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/E-book_DHTML_AJAX.zip">example code</a> (.zip) covers some topics I covered on this website as well as many others I have not, such as: the DOM, table sorting and highlighting, regular expressions, hide-show, pop-up windows, form validation and formatting, alertless error messages, date picker, google maps, and ajax basics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2008/07/02/dhtml-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eloquent JavaScript</title>
		<link>http://www.javascriptworkshop.com/2008/05/19/eloquent-javascript/</link>
		<comments>http://www.javascriptworkshop.com/2008/05/19/eloquent-javascript/#comments</comments>
		<pubDate>Mon, 19 May 2008 03:24:58 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=206</guid>
		<description><![CDATA[Marijn Haverbeke has put together an online book titled Eloquent JavaScript that not only has some nice content, but also incorporates a really cool integrated interface for editing and running the example programs. I would categorize these lessons as beginner to advanced so there is something for every level of developer. Introduction Basic JavaScript: values, [...]]]></description>
			<content:encoded><![CDATA[<p>Marijn Haverbeke has put together an online book titled <a class="externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/contents.html">Eloquent JavaScript</a> that not only has some nice content, but also incorporates a really cool integrated interface for editing and running the example programs. </p>
<p>I would categorize these lessons as beginner to advanced so there is something for every level of developer.</p>
<p><span id="more-206"></span></p>
<p><a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter1.html">Introduction</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter2.html">Basic JavaScript: values, variables, and control flow</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter3.html">Functions</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter4.html">Data structures: Objects and Arrays</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter5.html">Error Handling</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter6.html">Functional Programming</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter7.html">Searching</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter8.html">Object-oriented Programming</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter9.html">Modularity</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter10.html">Regular Expressions</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter11.html">Web programming: A crash course</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter12.html">The Document-Object Model</a><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter13.html">Browser Events<a/><br />
<a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/EloquentJavaScript/chapter14.html">HTTP requests</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2008/05/19/eloquent-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DOM Cheatsheet</title>
		<link>http://www.javascriptworkshop.com/2007/08/14/dom-cheatsheet/</link>
		<comments>http://www.javascriptworkshop.com/2007/08/14/dom-cheatsheet/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 08:25:30 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Chris Heilmann]]></category>
		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=154</guid>
		<description><![CDATA[Chris Heilmann created a nice DOM Cheatsheet (.pdf) to help all us would-be JavaScript developers.]]></description>
			<content:encoded><![CDATA[<p>Chris Heilmann created a nice <a class = "externalLink" href = "http://www.javascriptworkshop.com/wp-content/uploads/pdf/JavaScript-DOM-Cheatsheet.pdf">DOM Cheatsheet</a> (.pdf) to help all us would-be JavaScript developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/08/14/dom-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a JavaScript Jump Menu</title>
		<link>http://www.javascriptworkshop.com/2007/07/06/jump-menu/</link>
		<comments>http://www.javascriptworkshop.com/2007/07/06/jump-menu/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 05:42:45 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Jump Menu]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/2007/07/06/jump-menu/</guid>
		<description><![CDATA[Nowadays there are many elaborate ways to create navigation to access pages on your website. Back in the early days of JavaScript, &#8220;Jump Menus&#8221; were used a lot to create simple navigation to various web pages. These have been replaced by more elaborate JavaScript menu systems that use hundreds of lines of code. This technique [...]]]></description>
			<content:encoded><![CDATA[<p>Nowadays there are many elaborate ways to create navigation to access pages on your website.  Back in the early days of JavaScript, &#8220;Jump Menus&#8221; were used a lot to create simple navigation to various web pages. These have been replaced by more elaborate JavaScript menu systems that use hundreds of lines of code.  This technique can still come in handy in certain situations and is good practice for anybody wanting to learn.</p>
<p><span id="more-202"></span></p>
<p>Basically it is accomplished by taking a HTML menu control<br />
<option> and using its values with JavaScript methods to &#8220;redirect&#8221; the visitor to another web page. The JavaScript would just find the selected option item and using the <strong>window.location</strong> method to direct to the new web page.</p>
<p>For a detailed explanation, check out this <a href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/javascript/videos/jumpmenu/JumpMenu.zip">video</a> (.zip) narrated by Dori Smith as well as the <a class = "externalLink" href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/javascript/videos/jumpmenu/jumpmenu.html">online example</a> and <a href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/javascript/videos/jumpmenu/JumpMenu_code.zip">code</a> (.zip).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/07/06/jump-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hiding and Showing</title>
		<link>http://www.javascriptworkshop.com/2007/06/01/hiding-and-showing/</link>
		<comments>http://www.javascriptworkshop.com/2007/06/01/hiding-and-showing/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 00:31:53 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=106</guid>
		<description><![CDATA[The visibilty of an element is a powerful tool that can be used in JavaScript to create everything from animations and effects to fast templating. More importantly, however, it can also be used to quickly hide an element from view, providing users with some basic user interaction capabilities. Within CSS there are two different ways [...]]]></description>
			<content:encoded><![CDATA[<p>The visibilty of an element is a powerful tool that can be used in JavaScript to create everything from animations and effects to fast templating.  More importantly, however, it can also be used to quickly hide an element from view, providing users with some basic user interaction capabilities.</p>
<p>Within CSS there are two different ways of effectively hiding an element from view; both have their benefits but can provide unintented consquences, depending on how you use them:</p>
<p><span id="more-106"></span></p>
<p>The <strong>visibility</strong> property toggles whether an element is visible or not, while still leaving its normal flow properties intact.  The visibility property has two values: visible (default) and hidden.  </p>
<p>The <strong>display</strong> property provides more options to a developer for controlling the layout of an element.  The options for it vary between inline, block and none (which completely hides an element from the document.  The result of setting a display property of an element looks exactly the same as if you had just removed the element from the document.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span>  hideshow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> elem <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hideshow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>elem.<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: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
         elem.<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>
&nbsp;
     <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
         elem.<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></pre></div></div>

<p>Since we are separating behavior from presentation we should make our link behave like a link too.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">link.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     hideshow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
link.<span style="color: #660066;">onmouseover</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">cursor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Put this all together into a <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/hide_show/hide_show.html">simple example</a>. Download the <a href = "http://www.javascriptworkshop.com/PHPWebHost/hide_show/hide_show.zip">code</a> (.zip) if you want as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/06/01/hiding-and-showing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Styling with the DOM</title>
		<link>http://www.javascriptworkshop.com/2007/05/14/css-dom/</link>
		<comments>http://www.javascriptworkshop.com/2007/05/14/css-dom/#comments</comments>
		<pubDate>Mon, 14 May 2007 00:25:38 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Styling]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=105</guid>
		<description><![CDATA[Every element in a document is an object. Every one of these objects has a whole collection of properties as we have discussed in previous meetings. There&#8217;s one property called style which every element node has. It contains information about the styles attached to the element. Querying this property doesn’t return a simple string, it [...]]]></description>
			<content:encoded><![CDATA[<p>Every element in a document is an object.  Every one of these objects has a whole collection of properties as we have discussed in previous meetings.  There&#8217;s one property called <strong>style</strong> which every element node has.  It contains information about the styles attached to the element.  Querying this property doesn’t return a simple string, it returns an object.  Style information is stored as properties of this style object:</p>
<p><i>element.style.property</i></p>
<p><span id="more-105"></span></p>
<p>Here’s an example of a paragraph with some inline styling:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span> <span style="color: #66cc66;">=</span> ”example” <span style="color: #000066;">style</span> <span style="color: #66cc66;">=</span> “font-family: ‘Arial’, san-serif;”&gt;</span>
An example of a paragraph.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>Using the style property you can retrieve this stylistic information.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> para <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>“example”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To verify that the style property is an object:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> para.<span style="color: #660066;">style</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><img src = "http://www.javascriptworkshop.com/anim_style_screen1.gif" border = "0"><br/><br />
To retrieve the the font of the style:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>para.<span style="color: #660066;">style</span>.<span style="color: #660066;">fontfamily</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><img src = "http://www.javascriptworkshop.com/anim_style_screen2.gif" border = "0"><br/><br />
The DOM camelCases style properties that have more than one word.  The CSS property &#8220;font-family&#8221; becomes the DOM property fontFamily.</p>
<table class = "dom_anim">
<tr>
<td><strong>CSS</strong></td>
<td><strong>DOM</strong></td>
</tr>
<tr>
<td>background-color</td>
<td>backgroundColor</td>
</tr>
<tr>
<td>font-size</td>
<td>fontSize</td>
</tr>
<tr>
<td>font-family</td>
<td>fontFamily</td>
</tr>
<tr>
<td>z-index</td>
<td>zIndex</td>
</tr>
</table>
<p>There is a big caveat to retieving stylistic information with the style property.  The style property only returns inline style information.  So if you add an external style sheet or even put the style in the <head> tags it will not retrieve the information.</p>
<p>So the really only good use of using the style property is if you apply stylistic information via the DOM. If you do this it will pick it up as if it were inline.  This is useful if you are dynamically updating or modifying elements on a page and want to also change the style of those particular elements for a more visual effect. (table hightlighing, form validation, hiding/showing, drag and drop, animation, etc.) </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/05/14/css-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submitting a Form by Enter key</title>
		<link>http://www.javascriptworkshop.com/2007/03/16/submitting-a-form-by-enter-key/</link>
		<comments>http://www.javascriptworkshop.com/2007/03/16/submitting-a-form-by-enter-key/#comments</comments>
		<pubDate>Fri, 16 Mar 2007 01:07:37 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Submitting Enter key]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/2007/03/16/submitting-a-form-by-enter-key/</guid>
		<description><![CDATA[Depending on the browser type and configuration, pressing the Enter key while in a form does not always submit the form. Sometimes, for instance, the button that submits the form resides in another frame. In that case, adding a bit of JavaScript to ensure that the Enter key sends the form data, as well, comes [...]]]></description>
			<content:encoded><![CDATA[<p>Depending on the browser type and configuration, pressing the Enter key while in a form does not always submit the form.  Sometimes, for instance, the button that submits the form resides in another frame.  In that case, adding a bit of JavaScript to ensure that the Enter key sends the form data, as well, comes in handy.</p>
<p><span id="more-178"></span></p>
<p>All that is necessary to implement for that function is a standard key listener: Keyboard events are not part of DOM Level 1 or Level 2, but are still implemented in recent browsers.  </p>
<p>Accessing the event differs from the usual approach (window.event in Internet Explorer; the event as the automatic parameter of the function in all other browsers).  But then, the keyCode property returns the ASCII code of the key, which can then be processed, as in the following example:</p>
<p>The key code for the Enter key is 13, so when this code is found, the form is submitted:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> checkKey<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">key</span>;
&nbsp;
     <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>window.<span style="color: #006600;">event</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
          <span style="color: #0066CC;">key</span> = window.<span style="color: #006600;">event</span>.<span style="color: #006600;">keyCode</span>;
&nbsp;
     <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
          <span style="color: #0066CC;">key</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">keyCode</span>;
&nbsp;
     <span style="color: #66cc66;">&#125;</span>
&nbsp;
     <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">key</span> == <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
          document.<span style="color: #006600;">forms</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">submit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
     <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
window.<span style="color: #0066CC;">onload</span> = <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
     document.<span style="color: #006600;">forms</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">elements</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;field&quot;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">onkeydown</span> = checkKey;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/03/16/submitting-a-form-by-enter-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Arguments Array</title>
		<link>http://www.javascriptworkshop.com/2007/03/11/function-arguments-array/</link>
		<comments>http://www.javascriptworkshop.com/2007/03/11/function-arguments-array/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 21:47:37 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=152</guid>
		<description><![CDATA[Inside every function in JavaScript there exists a contextual variable named arguments that acts like a pseudo-array. This object contains all the arguments passed in to the function. Arguments isn&#8217;t a true array (meaning that you can&#8217;t modify it, or call .push() to add new items), but you can access items in the array, and [...]]]></description>
			<content:encoded><![CDATA[<p>Inside every function in JavaScript there exists a contextual variable named <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions:arguments">arguments</a> that acts like a pseudo-array. This object contains all the arguments passed in to the function.  Arguments isn&#8217;t a true array (meaning that you can&#8217;t modify it, or call .push() to add new items), but you can access items in the array, and it does have a length property.</p>
<p><span id="more-152"></span></p>
<p>Even if you don&#8217;t declare any argument names in your function declaration, you can actually pass one or more arguments when you call the function.  This can be useful for writing functions that will accept any number of arguments.</p>
<p>Imagine we called a function with these arguments:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">debate <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;affirmative&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;negative&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We could access those arguments via the arguments array inside the function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> debate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> affirmative <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">var</span> negative <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Or check to make sure a specific number of arguments were passed to the function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> debate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">!=</span><span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is something I just noticed and isn&#8217;t normally mentioned in most beginner JavaScript books.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/03/11/function-arguments-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Viewers: Lightbox JS 2.0</title>
		<link>http://www.javascriptworkshop.com/2007/03/05/image-viewers-using-lightbox-js-20/</link>
		<comments>http://www.javascriptworkshop.com/2007/03/05/image-viewers-using-lightbox-js-20/#comments</comments>
		<pubDate>Mon, 05 Mar 2007 01:53:48 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Flash Image Viewers]]></category>
		<category><![CDATA[JavaScript Image Viewers]]></category>
		<category><![CDATA[Lightbox]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=102</guid>
		<description><![CDATA[Lightbox JS is an unobtrusive script that is used to overlay images on a web page. This script uses the Prototype and Scriptaculous JavaScript libraries as well. By using functionality of these two libraries, the script produces some very nice animations in displaying your images. To get started, all the necessary scripts are included in [...]]]></description>
			<content:encoded><![CDATA[<p><a class = "externalLink" href = "http://www.huddletogether.com/projects/lightbox2/">Lightbox JS</a> is an unobtrusive script that is used to overlay images on a web page.  This script uses the Prototype and Scriptaculous JavaScript libraries as well.  By using functionality of these two libraries, the script produces some very nice animations in displaying your images.</p>
<p><span id="more-102"></span></p>
<p>To get started, all the necessary scripts are included in one download from their web site.  I created a simple <a class = "externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/Lightbox/lightbox.html">example</a> to show you how it would look.</p>
<p>The main disadvantage of this script is that the other required libraries are a little large, so it may take a little while to initially load.  You can checkout other JavaScript versions of Lightbox JS such as <a class="externalLink" href="http://jquery.com/demo/thickbox/">ThickBox</a>, <a class="externalLink" href="http://www.jasons-toolbox.com/SlightlyThickerbox/">Slightly ThickerBox</a>, <a class="externalLink" href="http://www.doknowevil.net/litebox/">Litebox</a>, <a class="externalLink" href="http://www.ibegin.com/labs/ibox/">iBox</a> and so forth.</p>
<p>Apart from using JavaScript for images, you can use Adobe Flash as well. </p>
<p>There are many free ones that use Flash such as from the company <a class="externalLink" href = "http://www.airtightinteractive.com/news/">Airtight Interactive</a>, such as <a class="externalLink" href = "http://www.airtightinteractive.com/projects/autoviewer/">AutoViewer</a>, <a class="externalLink" href = "http://www.airtightinteractive.com/simpleviewer/">SimpleViewer</a>, <a class="externalLink" href = "http://www.airtightinteractive.com/projects/postcardviewer/">PostCardViewer</a>, and <a class="externalLink" href = "http://www.airtightinteractive.com/projects/tiltviewer/">TiltViewer</a>.</p>
<p>I zipped all their <a href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/Airtight_Free_FlashViewers.zip">free flash viewers</a> (.zip) for you to checkout.</p>
<p>All you do is update an .xml file with the image information (url, caption, styling, etc.). </p>
<p>You can buy the &#8220;Pro&#8221; versions of these which include the source (.fla) files so you can customize how it looks completely.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/03/05/image-viewers-using-lightbox-js-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alter Table Row Background Colors</title>
		<link>http://www.javascriptworkshop.com/2007/03/02/alter-table-row-background-colors/</link>
		<comments>http://www.javascriptworkshop.com/2007/03/02/alter-table-row-background-colors/#comments</comments>
		<pubDate>Fri, 02 Mar 2007 00:59:10 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Styling]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=135</guid>
		<description><![CDATA[Many sites that present tabular data use alternating background colors to increase the readability of that data. The obvious solution is to hardcode every second row to ensure it had a different background color. But if you want the table to be dynamic, meaning that it would be possible to add a new row in [...]]]></description>
			<content:encoded><![CDATA[<p>Many sites that present tabular data use alternating background colors to increase the readability of that data.  The obvious solution is to hardcode every second row to ensure it had a different background color. But if you want the table to be dynamic, meaning that it would be possible to add a new row in the middle of the table without changing the background color attribute of the rows that followed requires a little JavaScript.</p>
<p><span id="more-135"></span></p>
<p>A fairly simple function is all you need:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> alternate<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #006600; font-style: italic;">// object detection</span>
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #006600; font-style: italic;">// reference the table (id) and the rows (&quot;tr&quot;)</span>
          <span style="color: #003366; font-weight: bold;">var</span> table <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
          <span style="color: #003366; font-weight: bold;">var</span> rows <span style="color: #339933;">=</span> table.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
&nbsp;
          <span style="color: #006600; font-style: italic;">// loop through the table rows</span>
          <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> rows.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// %, gives remainder in division</span>
               <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">%</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
                    rows<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;even&quot;</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> 
                    rows<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;odd&quot;</span><span style="color: #339933;">;</span> 
               <span style="color: #009900;">&#125;</span>       
          <span style="color: #009900;">&#125;</span> 
     <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then add your CSS styles to your stylesheet:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.odd</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span> 
<span style="color: #6666ff;">.even</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/Alter_Row/table.html">simple example</a> shows how it would look and here is the <a href = "http://www.javascriptworkshop.com/PHPWebHost/Alter_Row/alter_rows.zip">code</a> (.zip) as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/03/02/alter-table-row-background-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s Wrong with Popups?</title>
		<link>http://www.javascriptworkshop.com/2007/02/22/whats-wrong-with-popups/</link>
		<comments>http://www.javascriptworkshop.com/2007/02/22/whats-wrong-with-popups/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 19:43:15 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Popups]]></category>
		<category><![CDATA[Presentational Markup]]></category>
		<category><![CDATA[Unobtrusiveness]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=139</guid>
		<description><![CDATA[Should you use popup windows? Popup windows have gained a bad reputation from marketers&#8217; aggressive use of them, but even requested popups can be barriers to good usability. There are situations where popping a new window is arguably the most appropriate solution. Popups are mostly used for one-page interfaces or those in which history navigation [...]]]></description>
			<content:encoded><![CDATA[<p>Should you use popup windows?  Popup windows have gained a bad reputation from marketers&#8217; aggressive use of them, but even requested popups can be barriers to good usability.   There are situations where popping a new window is arguably the most appropriate solution.  Popups are mostly used for one-page interfaces or those in which history navigation is discouraged, such as a survey or a logon page for a commercial web site.</p>
<p><span id="more-139"></span></p>
<p><strong>So what is wrong with popups?</strong></p>
<p>1. popups are generated from links, though those links do nothing when scripting is not available<br />
2. popup windows that don&#8217;t have a status bar, so you can&#8217;t necessarily tell whether the document has loaded or stalled, is still loading, etc.<br />
3. popups that don&#8217;t give users the ability to resize the window, and popups that fail to generate scrollbars for content that might scale outside the window.<br />
4. windows that are &#8220;chromeless&#8221; or open to the full size of the user&#8217;s screen</p>
<p>These issues are not just questions of usability, but of accessibility as well.  For example, screen-reader users may not be notified by their devices that a new window has opened.  This could obviously case confusion if they then attempted to go back in the browser history (they can&#8217;t).  The same thing might happen for a sighted ser is a window opens at full-size: you and I may be familiar with using the taskbar to monitor open windows, but not all computer users are &#8212; they may not even realize that a new window has popped up.</p>
<p>Also, bear in mind that, from a developer&#8217;s perspective, popup windows are not guaranteed to work: most browsers now include options to suppress popup windows, and in some cases suppression occurs even if the popup is generated in response to a ser event. </p>
<p><strong>How Do I Minimize the Problems?</strong></p>
<p>1. Make sure any triggering link degrades properly when scripting is not available.<br />
2. Always include the status bar.<br />
3. Always include a mechanism to overflow the content: either allow window resizing, or allow scrollbars to appear, or both.<br />
4. Don&#8217;t open windows that are larger than 640&#215;480 pixels.</p>
<p>Here is a generic <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/Popup/popup.html">popup function</a> created by <a class = "externalLink" href = "http://www.themaninblue.com/">Cameron Adams</a> that’s based on the guidelines above as well as the <a href = "http://www.javascriptworkshop.com/PHPWebHost/Popup/Popup.zip">code</a> (.zip) for you to review. </p>
<p>The <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/DOM:window.open">window.open</a> method can take a number of arguments in addition to the URL and window name which specifies whether the window should have particular decorations, such as the menu bar, tool bar, or address (location) bar.  These arguments are passed as a comma-delimited string to the third argument of window.open.</p>
<p>In popup function, the menubar, toolbar and location arguments are all preset to no because these elements are rarely useful for popup windows &#8212; they&#8217;re navigation tools after all.</p>
<p>Once a new window is open, you can bring it to focus using the object&#8217;s <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/DOM:window.focus">focus</a> method.  This isn&#8217;t usually necessary since it generally happens by default.  But it may come in handy if you&#8217;re opening multiple windows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> cpanel <span style="color: #339933;">=</span> makePopup<span style="color: #009900;">&#40;</span>cpanel.<span style="color: #660066;">html</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">480</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'resize'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cpanel.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Alternatively, you may want to open a popup but keep focus in the primary window (thereby creating a so-called &#8220;popunder&#8221;). You can take the focus away from a window using its <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/DOM:window.blur">blur</a> method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> cpanel <span style="color: #339933;">=</span> makePopup<span style="color: #009900;">&#40;</span>cpanel.<span style="color: #660066;">html</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">480</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'resize'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cpanel.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/02/22/whats-wrong-with-popups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a Hover Effect in IE6 versus IE7</title>
		<link>http://www.javascriptworkshop.com/2007/01/20/adding-a-hover-effect/</link>
		<comments>http://www.javascriptworkshop.com/2007/01/20/adding-a-hover-effect/#comments</comments>
		<pubDate>Sat, 20 Jan 2007 01:59:15 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Hover Effect]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Styling]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=89</guid>
		<description><![CDATA[One way to enhance a table style is to introduce a hover effect on the table rows: when the user is moving across the table with their mouse, the current row they are on will change color.  This is something that you frequently see in interface design in internal web applications which help users view [...]]]></description>
			<content:encoded><![CDATA[<p>One way to enhance a table style is to introduce a hover effect on the table rows: when the user is moving across the table with their mouse, the current row they are on will change color.  This is something that you frequently see in interface design in internal web applications which help users view a particlar row of data.</p>
<p><span id="more-89"></span></p>
<p>Creating a hover effect in Internet Explorer 7, Opera 9 or Firefox is pretty straight forward since all you have to do is use the CSS :hover dynamic pseudo-class on elements other than links. It would look like something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">table<span style="color: #6666ff;">.class</span> tr<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> 
       <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#AAAAAA</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFFFFF</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>In Internet Explorer 6 it is only supported on links, so you have to use a little JavaScript.</p>
<p>Here is an <a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/table_highlight/index.html">example</a> of using JavaScript to plug the holes in browser support for CSS and here is the <a href="http://www.javascriptworkshop.com/PHPWebHost/table_highlight/table_highlight.zip">code</a> (.zip) too.  The important job, however, is to make your table usable without the highlighting.  That way, it doesn&#8217;t matter to your users if they don&#8217;t get the highlighting effect, which will still be the case if they have JavaScript turned off in Internet Explorer 6. </p>
<p>Hopefully, with the IE7 adoption rate steadily increasing, support for IE6 will become less of a neccessity and more of a niceity. <img src='http://www.javascriptworkshop.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/01/20/adding-a-hover-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ternary Operator</title>
		<link>http://www.javascriptworkshop.com/2007/01/10/ternary-operator/</link>
		<comments>http://www.javascriptworkshop.com/2007/01/10/ternary-operator/#comments</comments>
		<pubDate>Wed, 10 Jan 2007 22:47:34 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=148</guid>
		<description><![CDATA[Using many if or switch statements can make your code very long and complex in no time. A trick to avoid some of the bloating involves using something called the ternary operator. The ternary operator syntax is: var variable = condition ? trueValue:falseValue; This is very handy for boolean conditions or very short values. For [...]]]></description>
			<content:encoded><![CDATA[<p>Using many if or switch statements can make your code very long and complex in no time.  A trick to avoid some of the bloating involves using something called the <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Operators:Special_Operators">ternary operator</a>.</p>
<p>The ternary operator syntax is:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> variable <span style="color: #339933;">=</span> condition <span style="color: #339933;">?</span> trueValue<span style="color: #339933;">:</span>falseValue<span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-148"></span></p>
<p>This is very handy for boolean conditions or very short values.</p>
<p>For example, you can replace this long if condition with one line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Normal syntax</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> direction<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    direction <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>  <span style="color: #000066; font-weight: bold;">else</span>  <span style="color: #009900;">&#123;</span>
&nbsp;
    direction <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Ternary operator</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> direction <span style="color: #339933;">=</span> x <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">200</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/01/10/ternary-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Waiting for the DOM to Load</title>
		<link>http://www.javascriptworkshop.com/2006/12/05/waiting-for-the-dom-to-load/</link>
		<comments>http://www.javascriptworkshop.com/2006/12/05/waiting-for-the-dom-to-load/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 11:27:49 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=138</guid>
		<description><![CDATA[As we have started to learn about the DOM this season, one thing that is an issue when developing your scripts is knowing when you can have your scripts execute. Remember, the DOM is available to you only when it has finished loading in the browser. You may ask, when has it finished loading? Good [...]]]></description>
			<content:encoded><![CDATA[<p>As we have started to learn about the DOM this season, one thing that is an issue when developing your scripts is knowing when you can have your scripts execute.  Remember, the DOM is available to you only when it has finished loading in the browser. You may ask, when has it finished loading? Good Question!</p>
<p>The order of completion that takes place inside a browser is roughly:</p>
<p>1. HTML is parsed<br />
2. External scripts/style sheets are loaded<br />
3. Scripts are executed as they are parsed in the document<br />
4. DOM is fully constructed<br />
5. Images and external content are loaded<br />
6. The page is finished loading</p>
<p><span id="more-138"></span><br />
Scripts that are in the header and loaded from an external file are executed before they DOM is actually constructed.  This is a problem because all script executed in those two places won&#8217;t have access to the DOM.  However, thankfully, there exists a number of workarounds for this problem.</p>
<p>The most common technique is to wait for the entire page to load before performing any DOM operations. Although it is the slowest technique, it is the safest, easiest and works on all browsers. You can do this using a nunber of ways. </p>
<p>One way is to just attach a function to the load event of the page.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;function&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Although functional, it is limited because you can only execute one function on the page load since only the last specified function will actually be executed. </p>
<p>You could create an anonymous function to hold the other functions and the last function (the anonymous one) will be executed last which then executes the functions you want:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     firstFunction<span style="color: #339933;">;</span>
     secondFunction<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This works fine, and it&#8217;s the simplest solution when you have a small number of functions.  </p>
<p>There&#8217;s another solution that scales quite nicely, no matter how many functions you want to execute when the page loads.  It takes a few more lines to setup initially but, once it&#8217;s in place, attaching functions to window.onload is an easy task. This function is called &#8220;addLoadEvent&#8221; and it was written by <a class  = "externalLink" href = "http://simonwillison.net/">Simon Willison</a>.  </p>
<p>It takes a single argument: the name of the function that you want to execute when the page loads.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> addLoadEvent<span style="color: #009900;">&#40;</span>func<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> oldonload <span style="color: #339933;">=</span> window.<span style="color: #000066;">onload</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> window.<span style="color: #000066;">onload</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> func<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>
          window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><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>oldonload<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    oldonload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
               func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here&#8217;s what addLoadEvent does:</p>
<p>1. Stores the exisiting window.onload as a variable called oldonload<br />
2. If this hasn&#8217;t yet had a function attached to it, then simply add the new function in the usal way<br />
3. If there is already a function attached, add the new function after the exisiting instrctions.</p>
<p>This effectively creates a queue of functions to be executed when the page loads.  To add functions to this queue you just need to write:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">addLoadEvent<span style="color: #009900;">&#40;</span>firstFunction<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
addLoadEvent<span style="color: #009900;">&#40;</span>secondFunction<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here is a <a href = "http://www.javascriptworkshop.com/wp-content/uploads/zip/javascript/videos/addloadevent/AddLoadEvent.zip"> video</a> (.zip) narrated by Dori Smith covering this same topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/12/05/waiting-for-the-dom-to-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Maps, Yahoo! Maps, Virtual Earth, MapQuest</title>
		<link>http://www.javascriptworkshop.com/2006/11/27/apis-google-maps-yahoo-maps-virtual-earth-mapquest/</link>
		<comments>http://www.javascriptworkshop.com/2006/11/27/apis-google-maps-yahoo-maps-virtual-earth-mapquest/#comments</comments>
		<pubDate>Mon, 27 Nov 2006 14:03:11 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[Yahoo Maps]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=68</guid>
		<description><![CDATA[Updated September 2009 The mapping APIs of these four have greatly changed since this post and I will be re-reviewing these in a future post. Code examples were removed. Since the emergence of Google Maps giving us the ability to put an interactive map on your own web page(s), there are now four separate APIs to choose from: [...]]]></description>
			<content:encoded><![CDATA[<div id="update"><strong>Updated September 2009</strong><br />
The mapping APIs of these four have greatly changed since this post and I will be re-reviewing these in a future post. Code examples were removed.</div>
<p>Since the emergence of Google Maps giving us the ability to put an interactive map on your own web page(s), there are now four separate <a class="externalLink" href="http://en.wikipedia.org/wiki/Application_programming_interface">APIs</a> to choose from: Google Maps, Yahoo! Maps, <del datetime="2009-09-19T17:49:39+00:00">Microsoft Virtual Earth</del> Bing Maps, and MapQuest. These APIs are similar, so once you understand one; it is just a matter of learning the differences of the others.</p>
<p>It&#8217;s pretty interesting noticing the visual and functional differences as you go back and forth looking at each one. Personally, I favor Google Maps because of its smooth interface, clean look, and easy to understand documentation, but Yahoo! Maps is a close second. </p>
<p>Yahoo! Maps also provides a <a class="externalLink" href="http://developer.yahoo.com/maps/flash/index.html">Flash API</a> version (see below) that can use either JavaScript or Flash ActionScript code. </p>
<p>Virtual Earth reminds me of the interfaces Microsoft has for many of its development products (which can be good or bad), but provides the most intriguing visual experience with its aerial and bird&#8217;s eye views. MapQuest is the new kid on the block and has the least visually entertaining experience, but incorporates its biggest strength with driving directions so it has some potential.</p>
<p>All of the APIs are built upon the theory of <a class="externalLink" href="http://en.wikipedia.org/wiki/Geocoding">geocoding</a>, but offer different implementations for allowing you to retrieve latitude/longitude points either within the JavaScript API or using external <a class="externalLink" href="http://en.wikipedia.org/wiki/REST">REST</a> calls. For the later, you will need to incorporate some server-side scripting (PHP, ASP, etc) to retrieve the information you want. If you do not want to be bothered with that, but need specific points (latitude/longitude) for an address(s) you can use websites such as <a class="externalLink" href="http://geocoder.us/">http://geocoder.us/</a> or you can use my simple <a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/google_maps/geocoding.html">geocoding example</a>.</p>
<p>There actually is another mapping API called <a class="externalLink" href="http://www.nn4d.com/site/global/build/apis_overview/p_overview.jsp">Map TP</a>, but requires that the browser have the Java Runtime installed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/11/27/apis-google-maps-yahoo-maps-virtual-earth-mapquest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Want a Cookie?</title>
		<link>http://www.javascriptworkshop.com/2006/11/08/want-a-cookie/</link>
		<comments>http://www.javascriptworkshop.com/2006/11/08/want-a-cookie/#comments</comments>
		<pubDate>Wed, 08 Nov 2006 05:31:22 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[Cookies]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=140</guid>
		<description><![CDATA[Cookies are really the only way in which you can share user data between two non-sequential web pages. Cookies allow you to store data on users’ systems and retrieve it in minutes, hours or even days later. This makes cookies perfect for remembering things like users&#8217; login names, which pages they visited last, what they [...]]]></description>
			<content:encoded><![CDATA[<p>Cookies are really the only way in which you can share user data between two non-sequential web pages.  Cookies allow you to store data on users’ systems and retrieve it in minutes, hours or even days later.  This makes cookies perfect for remembering things like users&#8217; login names, which pages they visited last, what they dropped into their shopping carts and when they did so.</p>
<p>Although server-side code is the most robust method of dealing with cookies, sometimes you need to manipulate cookies on the client side.  Luckily, JavaScript can read and write cookies in exactly the same way servers do.  Though the problem with JavaScript is that reading a cookie requires a little parsing to get them out. Don&#8217;t worry, I found a nice little function to the job for us.</p>
<p><span id="more-140"></span></p>
<p>Any script be it server or client-side can only read cookies that were set by a web page from the same domain.  Cookies are stored in the document object’s cookie property.  This property is actually a string that’s automatically generated by the browser when the page loads.  It concatenates all the valid cookie information stored for the current browser address, and makes it available to JavaScript via the DOM.</p>
<p>Within the cookie property, cookies are separated by a semicolon (;), and traditionally each cookie consists of a name/value pair separated by an equality sign (=). </p>
<p><strong>Writing a Cookie</strong></p>
<p>An example cookie string looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fur<span style="color: #339933;">=</span>blue<span style="color: #339933;">;</span> food<span style="color: #339933;">=</span>biscuits<span style="color: #339933;">;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span>Cookie_Monster</pre></div></div>

<p>The first step in creating a cookie is to create a string that reflects the name of your cookie, followed by =, followed by the value of the cookie:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> cookieName <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;login&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> cookieValue <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;choc_chip&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> theCookie <span style="color: #339933;">=</span> cookieName <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span> <span style="color: #339933;">+</span> cookieValue<span style="color: #339933;">;</span></pre></div></div>

<p><strong>note:</strong> When you create your cookie string, make sure that the name or value of the cookie does not include spaces, commas, or semicolons.  These characters can cause errors not only with the parsing of the cookie string, but with the sending of cookie data via HTTP headers. As an added precauttion when you create and get your cookie name/value data you can use the <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/DOM:window.escape">escape</a> and <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/DOM:window.unescape" >unescape</a> functions respectively.  These will convert and unconvert chracters that are not text or numbers into the hexadecimal equivalent of their character in the Latin-1 character set, preceded by a % character.</p>
<p>Once you’ve created your cookie string, you have to store it in the browser’s cookie jar.  Even though document.cookie is really just one string, it exhibits special behavior when JavaScript tries to write a cookie to it.  Assigning a cookie string to document.cookie does not overwrite the entire property, as it would for a normal string.  Instead, the cookie string is added to document.cookie. </p>
<p>If the cookie name already exists, the new value automatically replaces the current one:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> theCookie<span style="color: #339933;">;</span></pre></div></div>

<p>Your data is now a cookie! Imagine that document.cookie was originally:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fur<span style="color: #339933;">=</span>blue<span style="color: #339933;">;</span> food<span style="color: #339933;">=</span>biscuts<span style="color: #339933;">;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span>Cookie_Monster</pre></div></div>

<p>Now, it&#8217;s:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fur<span style="color: #339933;">=</span>blue<span style="color: #339933;">;</span> food<span style="color: #339933;">=</span>biscuts<span style="color: #339933;">;</span> <span style="color: #000066;">name</span><span style="color: #339933;">=</span>Cookie_Monster<span style="color: #339933;">;</span> login<span style="color: #339933;">=</span>choc_chip</pre></div></div>

<p>You can only add one cookie at a time, so even though you can replicate the cookie-semicolon-cookie syntax, you cannot concatenate a number of cookie strings together and add them to document.cookie in one go.</p>
<p><strong>Reading a Cookie</strong></p>
<p>It’s no good writing a cookie unless you can access it again.  The browser automatically fills document.cookie with all the valid cookies for the current domain, so there’s no chance that you’ll read something you’re not meant to.</p>
<p>There’s nothing glamorous about getting cookies out of document.cookie, you have to parse the string yourself and collect your own values.  But, once you understand the syntax of the cookie property, it’s fairly easy to break the process using a few <a class = "externalLink" href = "http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String:indexOf">indexOf</a> string method calls.  This handy function was found in Chapter 11 of the latest edition of <a class = "externalLink" href = "http://www.amazon.com/gp/product/0470051515?ie=UTF8&#038;tag=javascriptwor-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0470051515">Beginning JavaScript</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> value <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #003366; font-weight: bold;">var</span> startsAt <span style="color: #339933;">=</span> cookieValue.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>startsAt <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
&nbsp;
          startsAt <span style="color: #339933;">=</span> value.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>startsAt <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
&nbsp;
          value <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span> 
&nbsp;
     <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          startsAt <span style="color: #339933;">=</span> value.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">,</span> startsAt<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
          <span style="color: #003366; font-weight: bold;">var</span> endsAt <span style="color: #339933;">=</span> value.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;;&quot;</span><span style="color: #339933;">,</span> startsAt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>endsAt <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               endsAt <span style="color: #339933;">=</span> value.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> 
          <span style="color: #009900;">&#125;</span>
          value <span style="color: #339933;">=</span> value.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>startsAt<span style="color: #339933;">,</span> endsAt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #000066; font-weight: bold;">return</span> value<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> monsterName <span style="color: #339933;">=</span> getCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The value of the variable monsterName is now &#8220;Cookie_Monster&#8221;.</p>
<p>So you can use this <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/Cookie/cookie.html">simple example</a> to see it in action and <a href = "http://www.javascriptworkshop.com/PHPWebHost/Cookie/cookie.zip">download</a> (.zip) if you want too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/11/08/want-a-cookie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Timers in JavaScript</title>
		<link>http://www.javascriptworkshop.com/2006/11/07/timers/</link>
		<comments>http://www.javascriptworkshop.com/2006/11/07/timers/#comments</comments>
		<pubDate>Tue, 07 Nov 2006 23:19:11 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[JavaScript topics]]></category>
		<category><![CDATA[timers]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=218</guid>
		<description><![CDATA[Timers are a way to add a dynamic aspect to your web pages. They can be used to create animations, open or close windows, pop up a message to the user, and even destroy a cookie for security purposes. There are two types of timers: one that&#8217;s set once, and one that reoccurs over an [...]]]></description>
			<content:encoded><![CDATA[<p>Timers are a way to add a dynamic aspect to your web pages.  They can be used to create animations, open or close windows, pop up a message to the user, and even destroy a cookie for security purposes.  </p>
<p>There are two types of timers: one that&#8217;s set once, and one that reoccurs over an interval.  Both can be canceled, though the one-time timer method fires just once.</p>
<p><span id="more-218"></span></p>
<p>To create a nonrepeating timer, use the setTimeout method. It takes a minimum of two parameters: the function literal or function name to run the timer delay ends, and the length of the timer delay in milliseconds. If there are any parameters to send to the function, they are listed at the end of the cal, separated by commas.  The method returns the identifier of the timeout:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> tmOut <span style="color: #339933;">=</span> setTimeout <span style="color: #009900;">&#40;</span>func<span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;param1&quot;</span><span style="color: #339933;">,</span> param2<span style="color: #339933;">,</span> ..<span style="color: #339933;">,</span>param<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To clear the time out, use the clearTimeout method:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">clearTimeout<span style="color: #009900;">&#40;</span>tmout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you want the timer delay to repeat over an interval, use the setInterval.  This takes two parameters, the function name and the timer interval. As with setTimeout, it return an indetifier:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> tmOut <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;function&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Again to stop or cancel the interval timer, use the clearInterval method.  If you want to have a repeating delay but still use a function literal or pass in parameters, you can use setTimeout and reset the timer when the previously set timer expires.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/11/07/timers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

