<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Willem Stuursma &#187; javascript</title>
	<atom:link href="http://willem.stuursma.name/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://willem.stuursma.name</link>
	<description>Passionate on product and programming</description>
	<lastBuildDate>Tue, 31 Jan 2012 10:26:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='willem.stuursma.name' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Willem Stuursma &#187; javascript</title>
		<link>http://willem.stuursma.name</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://willem.stuursma.name/osd.xml" title="Willem Stuursma" />
	<atom:link rel='hub' href='http://willem.stuursma.name/?pushpress=hub'/>
		<item>
		<title>element.focus() differences between browsers</title>
		<link>http://willem.stuursma.name/2010/10/20/element-focus-differences-between-browsers/</link>
		<comments>http://willem.stuursma.name/2010/10/20/element-focus-differences-between-browsers/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 21:04:04 +0000</pubDate>
		<dc:creator>stuursma</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://willem.stuursma.name/?p=294</guid>
		<description><![CDATA[Element.focus() can be used to change the focus in the browser to a certain element in your document. Usually, you set the focus to form elements such as &#60;input /&#62; or &#60;textarea /&#62;. The browser will then scroll the document so that the element is visible (if it is not visible yet) and place the caret [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=294&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Element.focus()</strong> can be used to change the focus in the browser to a certain element in your document. Usually, you set the focus to form elements such as &lt;input /&gt; or &lt;textarea /&gt;. The browser will then scroll the document so that the element is visible (if it is not visible yet) and place the caret in the element so that the user can start typing.</p>
<p>Many web sites, most notably search engines such as <a href="http://www.google.com/">Google</a> use this technique so that the user can start typing the moment the page is loaded, without first clicking the input box.</p>
<pre>document.getElementById('q').focus();</pre>
<p>If you have a text element which already contains text, you have two options: you can place the caret at the beginning of the box or at the end of the box. Most browsers place the caret at the beginning of the box. This is usefull for example in a message center context, where the user replies to a message which is already in the textarea. You would like the user to enter his or her reply at on top of the quoted message.</p>
<p>This is the default behavior in Internet Explorer and all webkit (Chrome, Safari) browsers. However, Firefox places the browser by default at the end of the textarea (or text input field). Focus() does not take any parameters, so we have to move the caret some other way.</p>
<p>We can create a selection of zero characters at the beginning of the text in the textbox. This wil move the caret to the beginning of the textarea:</p>
<pre>document.getElementById('q').setSelectionRange(0,0);</pre>
<p>However, this function is not supported by Internet Explorer, which is not really a problem since that browser&#8217;s behavior was as desired. So just detect if the function is available:</p>
<pre>element = document.getElementById('q');
element.focus();
if (element.setSelectionRange) {
    element.setSelectionRange(0,0);
}</pre>
<p>Using this snippet, you can move the caret to the beginning of a textarea of input element cross-browser. I hope this can help you if you encounter this issue. If you have any questions, do not hesitate to leave a comment below.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/willemst.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/willemst.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/willemst.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=294&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://willem.stuursma.name/2010/10/20/element-focus-differences-between-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eeeed33e97bb956677957d0e24700c36?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stuursma</media:title>
		</media:content>
	</item>
		<item>
		<title>Using BOSH to create a real-time, Javascript chat client</title>
		<link>http://willem.stuursma.name/2009/08/31/using-bosh-to-create-a-real-time-javascript-chat-client/</link>
		<comments>http://willem.stuursma.name/2009/08/31/using-bosh-to-create-a-real-time-javascript-chat-client/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 08:56:19 +0000</pubDate>
		<dc:creator>stuursma</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[clientside]]></category>
		<category><![CDATA[prototypejs]]></category>

		<guid isPermaLink="false">http://willemst.wordpress.com/?p=119</guid>
		<description><![CDATA[For iWink I have written a short article about the development of a Javascript only chat-client. Deze techniek werkt als volgt: zodra een webpagina is geladen, zorgt een stukje code op deze pagina ervoor dat in de achtergrond nog een extra verbinding gemaakt wordt met de webserver. De webserver laat deze verbinding open staan en [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=119&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For iWink I have written a short article about the development of a Javascript only chat-client.</p>
<blockquote><p>Deze techniek werkt als volgt: zodra een webpagina is geladen, zorgt een stukje code op deze pagina ervoor dat in de achtergrond nog een extra verbinding gemaakt wordt met de webserver. De webserver laat deze verbinding open staan en geeft geen antwoord, totdat er een chatbericht voor deze bezoeker ontvangen wordt. De webserver stuurt dan het chatbericht over de al gereedstaande verbinding. Hiermee kan een chatbericht binnen enkele honderden milliseconden afgeleverd worden.</p></blockquote>
<p>You can read the full article here: <a href="http://www.iwink.nl/lab/een-snellere-chatfunctie">A Faster Chat</a> (Dutch).</p>
<p>The chat module is written entirely in Javascript and is based on the <a href="http://www.prototypejs.org/">Prototype</a> framework. For effects and animations, <a href="http://script.aculo.us/">Script.aculo.us</a> is used. Some notes:</p>
<ul>
<li>It is <em>really</em> hard to detect if a connection is still in use with PHP. Of course there is <a href="http://nl.php.net/connection_aborted">connection_aborted()</a>, but this only works if a TCP RST packet has been received. This only happens when a user actually clickes the stop button in his or her browser, and with AJAX requests only when transport.abort() is invoked. The only solution is time-outs, but that&#8217;s not very responsive.</li>
<li>The chat uses long-living Apache processes. That&#8217;s okay when there are, say, less than fifty clients using the chat function at the same time, but when you would have more clients the server would quickly run out of memory. Fortunately, memory is cheap. If you need more clients, you could use <a href="http://www.facebook.com/note.php?note_id=14218138919&amp;comments">an HTTP server implementation in Erlang</a>, as Facebook has done.</li>
<li>It&#8217;s hard to create an event based system in PHP that does not tax the server too much. A MySQL table is continuously queried. Fortunately the MySQL Query Cache keeps the load acceptable. After each query, a short <a href="http://www.php.net/usleep">usleep()</a> command is issued.</li>
<li>Keeping connections open really saves on traffic. Open connections do not use any bytes. An AJAX polling method would use several hundreds of bytes per request on headers alone, this would quickly add up. Open connections use only bytes when there is something to send.</li>
<li>The chat client requires quite an amount of Javascript. In order to speed up delivery to the browser, we use the <a href="http://crisp.tweakblogs.net/blog/cat/716">JSMin++</a> Javascript minifier developed by <a href="http://crisp.tweakblogs.net/">Crisp</a>.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/willemst.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/willemst.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/willemst.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=119&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://willem.stuursma.name/2009/08/31/using-bosh-to-create-a-real-time-javascript-chat-client/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eeeed33e97bb956677957d0e24700c36?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stuursma</media:title>
		</media:content>
	</item>
		<item>
		<title>Google announces Google Maps API v3</title>
		<link>http://willem.stuursma.name/2009/06/13/google-announces-google-maps-api-v3/</link>
		<comments>http://willem.stuursma.name/2009/06/13/google-announces-google-maps-api-v3/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 18:53:59 +0000</pubDate>
		<dc:creator>stuursma</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://willemst.wordpress.com/?p=38</guid>
		<description><![CDATA[This week, Google announced the third version of their Google Maps API. At my work at iWink, I have done a lot of Google Maps implementations. Most were quite simple (just a map and some markers), however, other projects were more complicated. For example, for Marketing Groningen I implemented (together with my colleagues) Google Street [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=38&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This week, Google <a href="http://googlegeodevelopers.blogspot.com/2009/05/announcing-google-maps-api-v3.html">announced the third version</a> of their Google Maps API. At my work at <a href="http://www.iwink.nl/">iWink</a>, I have done a lot of Google Maps implementations. Most were quite simple (just a map and some markers), however, other projects were more complicated. For example, for <a href="http://toerisme.groningen.nl/">Marketing Groningen</a> I implemented (together with my colleagues) <a href="http://toerisme.groningen.nl/nederlands/hoofdmenu/vind-en-boek/streetview">Google Street View for Groningen</a>.</p>
<p>This new version builds upon the previous version. Unfortunately, the default namespace was changed from G* to google.maps.*. This seems like a good idea but will break every old implementation. So if you want to use any of the new versions in your existing implementation, you are out of luck.</p>
<p>Another change is that this version does not require an API key. This will enable the use of maps in different applications, such as RSS readers and probably on social networks as well.</p>
<p>Finally, there a are some improvements in speed and in supported browsers. Most mobile browsers are now supported too.</p>
<p>I am looking forward to working with this new API. It is not a GA release yet, so I won&#8217;t be able to use it at iWink. But I&#8217;ve got some personal projects as well that might benefit from new version.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/willemst.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/willemst.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/willemst.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=willem.stuursma.name&amp;blog=6028144&amp;post=38&amp;subd=willemst&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://willem.stuursma.name/2009/06/13/google-announces-google-maps-api-v3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eeeed33e97bb956677957d0e24700c36?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stuursma</media:title>
		</media:content>
	</item>
	</channel>
</rss>
