<?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>Stereo Interactive &#38; Design &#187; Javascript</title>
	<atom:link href="http://stereointeractive.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://stereointeractive.com/blog</link>
	<description>Development Blog</description>
	<lastBuildDate>Wed, 07 Jul 2010 19:16:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IE 6 getElementsById() and prototype $() function return dom elements by *name*</title>
		<link>http://stereointeractive.com/blog/2009/07/27/ie-6-getelementsbyid-and-prototype-function-return-dom-elements-by-name/</link>
		<comments>http://stereointeractive.com/blog/2009/07/27/ie-6-getelementsbyid-and-prototype-function-return-dom-elements-by-name/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 16:07:29 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://stereointeractive.com/blog/2009/07/27/ie-6-getelementsbyid-and-prototype-function-return-dom-elements-by-name/</guid>
		<description><![CDATA[I can&#8217;t believe I had not run into this yet, but today I had a page that had an element (an anchor) with a name attribute (&#8220;floorplans&#8221;), and further down the page a div with that id (&#8220;floorplans&#8221;). When I tried to dynamically load content into my div using $(&#8216;floorplans&#8217;), things were getting all out [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe I had not run into this yet, but today I had a page that had an element (an anchor) with a name attribute (&#8220;floorplans&#8221;), and further down the page a div with that id (&#8220;floorplans&#8221;). When I tried to dynamically load content into my div using $(&#8216;floorplans&#8217;), things were getting all out of control on IE 6. Turns out IE6&#8217;s document.getElementById returns the first element whose id OR name matches the string, and of course Prototype&#8217;s $() function relies on the browser&#8217;s own getElementById(). Lesson learned! </p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2009/07/27/ie-6-getelementsbyid-and-prototype-function-return-dom-elements-by-name/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Symfony: return javascript response</title>
		<link>http://stereointeractive.com/blog/2009/07/03/symfony-return-javascript-response/</link>
		<comments>http://stereointeractive.com/blog/2009/07/03/symfony-return-javascript-response/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 18:11:47 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=221</guid>
		<description><![CDATA[This is an old trick, but I still find it useful and will post it here in case it will help other symfony developers out there. If you are using the prototype.js library for your ajax requests, the Ajax.Request (and similar) utility methods will automatically evaluate the server&#8217;s response as javascript if the response has [...]]]></description>
			<content:encoded><![CDATA[<p>This is an old trick, but I still find it useful and will post it here in case it will help other symfony developers out there. If you are using the prototype.js library for your ajax requests, the Ajax.Request (and similar) utility methods will automatically evaluate the server&#8217;s response as javascript if the response has the &#8216;text/javascript&#8217; content-type header. <span id="more-221"></span>You can do this by setting your response headers like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span class="co1">// from within a template:</span>
sfContext<span class="sy0">::</span><span class="me2">getInstance</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">getResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">setContentType</span><span class="br0">&#40;</span><span class="st_h">'text/javascript'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="co1">// from your action</span>
<span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">getResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">setContentType</span><span class="br0">&#40;</span><span class="st_h">'text/javascript'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="co1">// as an action that returns some javascript directly</span>
<span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">getResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">setContentType</span><span class="br0">&#40;</span><span class="st_h">'text/javascript'</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw1">return</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">renderText</span><span class="br0">&#40;</span><span class="st0">&quot;alert('This is a javascript alert')&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

<p>This proves useful when you want to open up a modal window, show an alert, update multiple areas on a page, or just about anything else with javascript returned from your ajax request.</p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2009/07/03/symfony-return-javascript-response/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript get window hash/anchor, get link target</title>
		<link>http://stereointeractive.com/blog/2008/11/21/javascript-get-window-hashanchor-get-link-target/</link>
		<comments>http://stereointeractive.com/blog/2008/11/21/javascript-get-window-hashanchor-get-link-target/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 22:39:21 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=95</guid>
		<description><![CDATA[There are two functions I find myself using all the time. They are very useful for javascript events that read the link href attribute to determine an action&#8217;s target. 

function getHash&#40;&#41; &#123;
  var hash = window.location.hash;
  return hash.substring&#40;1&#41;; // remove #
&#125;
&#160;
function getLinkTarget&#40;link&#41; &#123;
  return link.href.substring&#40;link.href.indexOf&#40;'#'&#41;+1&#41;;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>There are two functions I find myself using all the time. They are very useful for javascript events that read the link href attribute to determine an action&#8217;s target. <span id="more-95"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span class="kw2">function</span> getHash<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
  <span class="kw2">var</span> <span class="kw3">hash</span> <span class="sy0">=</span> window<span class="sy0">.</span>location<span class="sy0">.</span><span class="kw3">hash</span><span class="sy0">;</span>
  <span class="kw1">return</span> <span class="kw3">hash</span><span class="sy0">.</span>substring<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// remove #</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw2">function</span> getLinkTarget<span class="br0">&#40;</span><span class="kw3">link</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
  <span class="kw1">return</span> <span class="kw3">link</span><span class="sy0">.</span>href<span class="sy0">.</span>substring<span class="br0">&#40;</span><span class="kw3">link</span><span class="sy0">.</span>href<span class="sy0">.</span>indexOf<span class="br0">&#40;</span><span class="st_h">'#'</span><span class="br0">&#41;</span><span class="sy0">+</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2008/11/21/javascript-get-window-hashanchor-get-link-target/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE6 mouseover event not firing, png filter</title>
		<link>http://stereointeractive.com/blog/2008/10/24/ie6-mouseover-event-not-firing/</link>
		<comments>http://stereointeractive.com/blog/2008/10/24/ie6-mouseover-event-not-firing/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 22:01:29 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=77</guid>
		<description><![CDATA[This took me way too long to figure out. I had a series of div tags that had mousover and mouseout events attached to them using prototype. I couldn&#8217;t get these events to fire in IE6 no matter what I tried! Events worked on links, but not any other element.
First thing to check: Are you [...]]]></description>
			<content:encoded><![CDATA[<p>This took me way too long to figure out. I had a series of div tags that had mousover and mouseout events attached to them using prototype. I couldn&#8217;t get these events to fire in IE6 no matter what I tried! Events worked on links, but not any other element.</p>
<p>First thing to check: Are you using the png filter trick?<br />
<code>filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop src='/images/white_bg.png');</code></p>
<p>If so, make sure your mouseover elements have &#8220;position:relative&#8221; or else the event won&#8217;t fire on any element inside another element with the png filter.</p>
<p><a href="http://www.quirksmode.org/bugreports/archives/2005/10/Mouseover_Not_Fired_In_Bottom_Padding_Border.html">This post</a> along got me on the right track.</p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2008/10/24/ie6-mouseover-event-not-firing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get value of radio button group using prototype</title>
		<link>http://stereointeractive.com/blog/2008/06/05/get-radio-button-value-using-prototype/</link>
		<comments>http://stereointeractive.com/blog/2008/06/05/get-radio-button-value-using-prototype/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 17:50:06 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://stereointeractive.com/blog/2008/06/05/get-radio-button-value-using-prototype/</guid>
		<description><![CDATA[If you want to get the value of the selected element of a radio group, prototype makes this easy. There is more than one way to do it. I&#8217;ll update this post as better methods surface. Check out code after the jump.


$$&#40;'input:checked[type=&#34;radio&#34;][name=&#34;my_radio_group&#34;]'&#41;.pluck&#40;'value'&#41;;

What this does is use css selectors to pull out an input element with [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to get the value of the selected element of a radio group, prototype makes this easy. There is more than one way to do it. I&#8217;ll update this post as better methods surface. Check out code after the jump.</p>
<p><span id="more-74"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span class="br0">&#40;</span><span class="st0">'input:checked[type=&quot;radio&quot;][name=&quot;my_radio_group&quot;]'</span><span class="br0">&#41;</span>.<span class="me1">pluck</span><span class="br0">&#40;</span><span class="st0">'value'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

<p>What this does is use css selectors to pull out an input element with the attribute &#8220;checked&#8221; of type &#8220;radio&#8221; and with the name&#8221;my_radio_group&#8221;. The $$ function returns an array, although in this case it is only one element long. &#8220;pluck&#8221; returns the given attribute (in our case we want the value attribute) for the elements in the array.</p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2008/06/05/get-radio-button-value-using-prototype/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Stereolabels released: updated labels.js for Prototype</title>
		<link>http://stereointeractive.com/blog/2007/08/15/stereolabels-released-updated-labelsjs-for-prototype/</link>
		<comments>http://stereointeractive.com/blog/2007/08/15/stereolabels-released-updated-labelsjs-for-prototype/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 08:25:42 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/08/15/stereolabels-released-updated-labelsjs-for-prototype/</guid>
		<description><![CDATA[Stereolabels unobtrusively places form input labels inside the form inputs themselves. Upon page load, the script crawls the DOM for labels with the specified class name (default is &#8216;inside&#8217;) and places the label text inside the input field. Upon clicking the field, the label is removed. When the element loses focus, if there is no [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Stereolabels</strong> unobtrusively places form input labels inside the form inputs themselves. Upon page load, the script crawls the DOM for labels with the specified class name (default is &#8216;inside&#8217;) and places the label text inside the input field. Upon clicking the field, the label is removed. When the element loses focus, if there is no input the label returns. This behavior is only applied to text, textarea, and password input fields.</p>
<p>Information and a download are available in our code section: <a href="http://blog.stereodevelopment.com/code/stereolabels/">Stereolabels</a></p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2007/08/15/stereolabels-released-updated-labelsjs-for-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sfCombineFilterPlugin released: Combine js and css requests into single compressed files</title>
		<link>http://stereointeractive.com/blog/2007/07/26/sfcombinefilterplugin-released/</link>
		<comments>http://stereointeractive.com/blog/2007/07/26/sfcombinefilterplugin-released/#comments</comments>
		<pubDate>Thu, 26 Jul 2007 16:31:26 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/07/26/sfcombinefilterplugin-released/</guid>
		<description><![CDATA[The sfCombineFilter plugin automatically combines included js and css files in your web response into one request each, passing the string of file names to a special php file that concatenates them and compresses them for faster delivery. This file is then cached for future use.
Information and download instructions are available in our code section: [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>sfCombineFilter</strong> plugin automatically combines included js and css files in your web response into one request each, passing the string of file names to a special php file that concatenates them and compresses them for faster delivery. This file is then cached for future use.</p>
<p>Information and download instructions are available in our code section: <a href="http://blog.stereodevelopment.com/code/sfcombinefilterplugin/">sfCombineFilter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2007/07/26/sfcombinefilterplugin-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prototype Tabs Script released, Scriptaculous Optional</title>
		<link>http://stereointeractive.com/blog/2007/07/23/new-prototype-tabs-script-released/</link>
		<comments>http://stereointeractive.com/blog/2007/07/23/new-prototype-tabs-script-released/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 01:45:10 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/07/23/new-prototype-tabs-script-released/</guid>
		<description><![CDATA[We just released a small script that allows you to easily create tabbed content on your web sites with a nice fade effect. Having searched for a decent script that uses prototype.js and scriptaculous to quickly create tabbed inline content and not having found one, we were inspired to create our own, much as stickmanlabs [...]]]></description>
			<content:encoded><![CDATA[<p>We just released a small script that allows you to easily create tabbed content on your web sites with a nice fade effect. Having searched for a decent script that uses prototype.js and scriptaculous to quickly create tabbed inline content and not having found one, we were inspired to create our own, much as stickmanlabs did with the <a href="http://stickmanlabs.com/accordion/">accordion script</a>. Check out the <a href="http://stereointeractive.com/blog/code/prototype-tabs/">prototype tabs demo.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2007/07/23/new-prototype-tabs-script-released/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Javascript Array Merge: array_merge</title>
		<link>http://stereointeractive.com/blog/2007/07/19/javascript-array-merge-array_merge/</link>
		<comments>http://stereointeractive.com/blog/2007/07/19/javascript-array-merge-array_merge/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 07:36:31 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/07/19/javascript-array-merge-array_merge/</guid>
		<description><![CDATA[Using protoype.js I discovered a quick way to merge to arrays in javascript:

function array_merge&#40;one, two&#41; &#123;
  one.push&#40;two&#41;;
  return one.flatten&#40;&#41;;
&#125;

This definitely beats the alternative of iterating through the second array by hand and adding it to the first. Any comments or suggestions are welcome.
]]></description>
			<content:encoded><![CDATA[<p>Using protoype.js I discovered a quick way to merge to arrays in javascript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">function</span> array_merge<span class="br0">&#40;</span>one<span class="sy0">,</span> two<span class="br0">&#41;</span> <span class="br0">&#123;</span>
  one.<span class="me1">push</span><span class="br0">&#40;</span>two<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">return</span> one.<span class="me1">flatten</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>

<p>This definitely beats the alternative of iterating through the second array by hand and adding it to the first. Any comments or suggestions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2007/07/19/javascript-array-merge-array_merge/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>javascript urlencode</title>
		<link>http://stereointeractive.com/blog/2007/05/14/javascript-urlencode/</link>
		<comments>http://stereointeractive.com/blog/2007/05/14/javascript-urlencode/#comments</comments>
		<pubDate>Mon, 14 May 2007 07:14:21 +0000</pubDate>
		<dc:creator>Scott Meves</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.stereodevelopment.com/?p=12</guid>
		<description><![CDATA[In doing a google search for javascript urlencode, I realized I was using that terminology just because I was familiar with the PHP function of the same name. Javascript&#8217;s method is actually called encodeURI() which will encode all characters except:
, / ? : @ &#38; = + $ #
But what I really wanted to do [...]]]></description>
			<content:encoded><![CDATA[<p>In doing a google search for javascript <strong>urlencode</strong>, I realized I was using that terminology just because I was familiar with the PHP function of the same name. Javascript&#8217;s method is actually called <strong>encodeURI() </strong>which will encode all characters except:</p>
<p><code>, / ? : @ &amp; = + $ #</code></p>
<p>But what I really wanted to do was get javascript to convert a string that would be okay to put into a query string of a URL. For this, use <strong>encodeURIComponent</strong>(). This will convert all characters except alphabetic, decimal digits, and:</p>
<p><code>- _ . ! ~ * ' ( )</code></p>
<p>That&#8217;s more like it. You can view the complete reference at <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent" title="encodeURIComponent" target="_blank">mozilla</a> or <a href="http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp" title="encodeURIComponent" target="_blank">w3schools</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://stereointeractive.com/blog/2007/05/14/javascript-urlencode/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
