<?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>The Web Development Blog &#187; Javascript</title>
	<atom:link href="http://www.thewebdevelopmentblog.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thewebdevelopmentblog.com</link>
	<description>News, tips, scripts and tutorials for web developers.</description>
	<lastBuildDate>Thu, 25 Aug 2011 11:15:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>JQuery 1.5(.1) now released</title>
		<link>http://www.thewebdevelopmentblog.com/2011/03/jquery-1-5-1-now-released/</link>
		<comments>http://www.thewebdevelopmentblog.com/2011/03/jquery-1-5-1-now-released/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 11:39:28 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.thewebdevelopmentblog.com/2011/03/jquery-1-5-1-now-released/</guid>
		<description><![CDATA[So because I&#8217;ve been too busy with developing and trying to keep up with everything else in life I really have not been able to update my blog for a while. So if you have been silly enough to check frequently then you&#8217;ve been bored and for that I&#8217;m sorry. But&#8230; Good news is jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>So because I&#8217;ve been too busy with developing and trying to keep up with everything else in life I really have not been able to update my blog for a while. So if you have been silly enough to check frequently then you&#8217;ve been bored and for that I&#8217;m sorry. But&#8230; Good news is jQuery 1.5 has been released then before I&#8217;ve even decided to write about it 1.5.1 has also been released.</p>
<p>I&#8217;ve been using it for a few weeks now and it has been so much more stable than 1.4.x &#8211; I pretty much bypassed that whole release as it was full of bugs and was a step backwards for jQuery in my opinion. 1.5.x has proven to redeem itself and proven to be faster and more stable then the previous 1.4.x release. Fingers crossed it stays that way and I don&#8217;t run into any major compatibility issues. 1.4.x was particularly unstable IE7. </p>
<p>You can get more details or download jQuery from <a href="http://www.jquery.com" target="_blank">jquery.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2011/03/jquery-1-5-1-now-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 hits the web.</title>
		<link>http://www.thewebdevelopmentblog.com/2010/01/jquery-1-4-hits-the-web/</link>
		<comments>http://www.thewebdevelopmentblog.com/2010/01/jquery-1-4-hits-the-web/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 05:09:02 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=419</guid>
		<description><![CDATA[In case you haven&#8217;t run around the web recently you may or may not have noticed jQuery 1.4 has just hit the web. The new release has a large list of improvements on features, speed increases as well as is highly backwards compatible which means most people can upgrade without any real hassles. Instead of [...]]]></description>
			<content:encoded><![CDATA[<p>In case you haven&#8217;t run around the web recently you may or may not have noticed jQuery 1.4 has just hit the web. The new release has a large list of improvements on features, speed increases as well as is highly backwards compatible which means most people can upgrade without any real hassles.</p>
<p><span id="more-419"></span></p>
<p>Instead of re-writing all the new features and speed improvements jump on the official release site for more details:</p>
<p><a href="http://jquery14.com/day-01/jquery-14" target="_blank">http://jquery14.com/day-01/jquery-14</a></p>
<p>Be sure to read the backwards incompatibilities at the bottom just to make sure nothing will break when you upgrade.</p>
<p>I&#8217;ll post a review once I&#8217;ve had a chance to put it through it&#8217;s paces properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2010/01/jquery-1-4-hits-the-web/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>7 Handy jQuery Plug-ins</title>
		<link>http://www.thewebdevelopmentblog.com/2009/09/7-handy-jquery-plug-ins/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/09/7-handy-jquery-plug-ins/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 12:14:27 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=291</guid>
		<description><![CDATA[What I love about jQuery is how it make coding Javascript much quicker and easier. Switching to jQuery after years of experience in Javascript felt like I was going backwards because of how much easier it is. jQuery is super powerful and now speedier than ever. But it&#8217;s greatest feature is the thousands of plug-ins [...]]]></description>
			<content:encoded><![CDATA[<p>What I love about <a href="http://www.jquery.com" target="_blank">jQuery</a> is how it make coding Javascript much quicker and easier. Switching to jQuery after years of experience in Javascript felt like I was going backwards because of how much easier it is. jQuery is super powerful and now speedier than ever. But it&#8217;s greatest feature is the thousands of plug-ins available for it. I&#8217;m going to have a look some of the handy jQuery plug-ins I&#8217;ve come across.</p>
<p><span id="more-291"></span></p>
<h2><strong><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">Web Form Validation</a></strong></h2>
<p>This plug-in is one that I will be using quite often. It takes the hassle out of coding a validation script for your web forms and works with 1 simple line of code. You can easily set which fields are required and what type of field it is in the form via simple meta data in the tag. You can also easily change the look of the error messages via css.</p>
<p><img class="alignnone size-full wp-image-292" title="Screen shot 2009-09-04 at 9.20.14 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-9.20.14-PM.png" alt="Screen shot 2009-09-04 at 9.20.14 PM" width="534" height="288" /></p>
<h2><a href="http://acko.net/dev/farbtastic" target="_blank">Farbtastic Color Picker</a></h2>
<p>More then just looks, this color picker is so easy to install you feel like you&#8217;re cheating! Works brilliantly and puts the hex straight into any input field ready for you to use in your web app.</p>
<p><img class="alignnone size-full wp-image-293" title="Screen shot 2009-09-04 at 9.23.35 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-9.23.35-PM.png" alt="Screen shot 2009-09-04 at 9.23.35 PM" width="209" height="257" /></p>
<h2><strong><a href="http://jquery.lukelutman.com/plugins/flash/" target="_blank">Flash</a></strong></h2>
<p>This plugin makes adding flash a little bit simpler and can easily handle your version checking for you.</p>
<p><img class="alignnone size-full wp-image-298" title="Screen shot 2009-09-04 at 9.48.20 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-9.48.20-PM.png" alt="Screen shot 2009-09-04 at 9.48.20 PM" width="330" height="206" /></p>
<h2><strong><a href="http://www.sohtanaka.com/web-design/simple-page-peel-effect-with-jquery-css/" target="_blank">Simple Page Peel</a></strong></h2>
<p>You&#8217;ve seen it everywhere, the ugly flash thing in the corner where you rollover it and it peels the page back to reveal some crazy offer. Well here is a jQuery implementation for it but unlike it&#8217;s flash brothers its not ugly!</p>
<p><img class="alignnone size-full wp-image-299" title="Screen shot 2009-09-04 at 10.00.40 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-10.00.40-PM.png" alt="Screen shot 2009-09-04 at 10.00.40 PM" width="441" height="383" /></p>
<h2><strong><a href="http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/" target="_blank">Cookies</a></strong></h2>
<p>Mmmmm, yum! No wait, this is the browser kind. This plugin gives you a simple way to create and delete cookies using Javascript.</p>
<p><img class="alignnone size-full wp-image-300" title="Screen shot 2009-09-04 at 10.03.59 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-10.03.59-PM.png" alt="Screen shot 2009-09-04 at 10.03.59 PM" width="497" height="85" /></p>
<h2><strong><a href="http://www.kelvinluck.com/assets/jquery/styleswitch/" target="_blank">Stylesheet Switcher</a></strong></h2>
<p>Speaks for itself, you can easily switch between CSS stylesheets.</p>
<h2><strong><a href="http://blue-anvil.com/jquerycurvycorners/test.html" target="_blank">Curvy Corners</a></strong></h2>
<p>Want cross browser curves without the hassle of corner images? This is for you. Not as smooth as the CSS3 code but it&#8217;ll work across all modern browsers.</p>
<p><img class="alignnone size-full wp-image-301" title="Screen shot 2009-09-04 at 10.10.55 PM" src="http://thewebdevelopmentblog.com/wp-content/uploads/2009/09/Screen-shot-2009-09-04-at-10.10.55-PM.png" alt="Screen shot 2009-09-04 at 10.10.55 PM" width="262" height="295" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/09/7-handy-jquery-plug-ins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript Libraries: Prototype or jQuery?</title>
		<link>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 04:18:46 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Javascript Libraries]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=272</guid>
		<description><![CDATA[A year ago the answer was easy, Prototype. Today jQuery has grown enormously and has the largest active community out of all the Javascript libraries. But is it the right choice for you? And what is a Javascript library anyway? What is a Javascript Library? Anyone who&#8217;s ever done serious coding with Javascript knows that [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago the answer was easy, Prototype. Today jQuery has grown enormously and has the largest active community out of all the Javascript libraries. But is it the right choice for you? And what is a Javascript library anyway?</p>
<p><span id="more-272"></span></p>
<p><strong>What is a Javascript Library?</strong></p>
<p>Anyone who&#8217;s ever done serious coding with Javascript knows that to get code to work cross-browser is a nightmare. Internet Explorer likes one way, Safari another, and Firefox another. It can be quite time consuming. This is where the Javascript libraries come to save the day! Hurray! Javascript libraries take the hassle out of coding for cross browser by extending Javascript so you don&#8217;t have to waste time developing for each browser.</p>
<p><strong>So which one to choose?</strong></p>
<p>There are two main Javascript libraries which are really in play, those are <a href="http://www.prototypejs.org" target="_blank">Prototype</a> and <a href="http://jquery.com/" target="_blank">jQuery</a>. There is also <a href="http://mootools.net/" target="_blank">MooTools</a>, however it is not anywhere near as widely used as Prototype and jQuery. That&#8217;s not to say it&#8217;s not as good, but I&#8217;m just going to compare the two leaders. It is important to note, there is no right or wrong answer, there is just preferences</p>
<p><strong>Prototype &#8211; The Grandfather</strong></p>
<p>It&#8217;s older but wiser. The key focus of Prototype is that it&#8217;s not really  designed to re-work the way Javascript is written, but to make your code more stable across more browsers and extented Javascript&#8217;s capabilities . Prototype builds on what&#8217;s already in Javascript, so you generally still get to do Javascript coding. It doesn&#8217;t build in fancy effects etc like jQuery does, it has it&#8217;s little sister <a href="http://script.aculo.us/" target="_blank">scriptaculous</a> to do that for it. One issue with Prototype is size, jQuery is available minified and gzipped, so it&#8217;s ready to go at 19kb. Prototype doesn&#8217;t have this available which is definitely hurting it&#8217;s numbers with younger developers. To gzip javascript yourself using PHP see my <a title="Jason Stockton, Web Developer, Javascript Gzip script" href="http://thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/" target="_blank">gzip script here</a>.</p>
<p>So why have I dubbed it &#8220;The Grandfather&#8221; and will this effect future development?</p>
<p>The problem with Prototype is it is becoming less and less active whilst jQuery becomes more and more active. More and more sites are switching to the hip young jQuery. Key switchers here are Twitter, Digg, NBC and the list goes on. So is the lack of progress going to affect it&#8217;s future? Right now no, but fast forward a year from now, if it&#8217;s still as inactive as it is now as newer browsers come out it&#8217;s going to quickly die out.</p>
<p>Prototype is still very stable and well featured, so it&#8217;s not to be overlooked.</p>
<p><strong>jQuery &#8211; The Cool Guy</strong></p>
<p>In contrast to Prototype, jQuery is built to reshape how Javascript is written and make it faster to write scripts. In short it does the hard work for you. jQuery is now the most widely used and supported Javascript library out there. There are literally hundreds of plugins, possibly thousands and the support is only growing. According to <a href="http://mootools.net/slickspeed/" target="_self">SlickSpeed</a> jQuery is significantly faster than Prototype, with the latest release said to be much much faster again. We&#8217;re only talking milliseconds so it&#8217;s not necessarily a huge deal but it&#8217;s always better to shave off time where possible.  It can take a bit of getting used to if you&#8217;re an advanced Javascript developer, but it seems like it will be of benefit in the long term. If you haven&#8217;t learnt Javascript before, jQuery can make it easier for you to get started making great scripts today.</p>
<p><strong>So which to choose?</strong></p>
<p>Ultimately it&#8217;s up to you, if you can&#8217;t decide, you can <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" target="_blank">use both</a>. I myself have been using Prototype for sometime and it is implemented in just about all of my sites AND I have built my own set of functions to compliment it. Having said that, the temptation to trial jQuery has gotten too great so I will be using both for a period of time before weening out Prototype now that jQuery can do pretty much all that Prototype can do, plus do it <strong>some of it</strong> easier.</p>
<p>They&#8217;re both great libraries and each have their pros and cons. jQuery is just hitting more of the pros today.</p>
<p><strong><a href="http://www.prototypejs.org" target="_blank">Download Prototype here</a></strong></p>
<p><strong><a href="http://jquery.com/" target="_blank">Download jQuery here</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/08/resource-javascript-libraries-prototype-or-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding &amp; working with &#8220;the loop&#8221; in WordPress templates.</title>
		<link>http://www.thewebdevelopmentblog.com/2009/06/tutorial-finding-working-with-the-loop-in-wordpress-templates/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/06/tutorial-finding-working-with-the-loop-in-wordpress-templates/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:28:43 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=235</guid>
		<description><![CDATA[So you know HTML, but not PHP &#8211; you&#8217;re trying to follow WordPress tutorials, they refer to the infamous &#8220;loop&#8221;&#8230; But where is it, what is it, and how do you find it? I&#8217;m going to run through &#8220;the loop&#8221; what it does and how to find it in your WordPress theme. What is it? [...]]]></description>
			<content:encoded><![CDATA[<p>So you know HTML, but not PHP &#8211; you&#8217;re trying to follow WordPress tutorials, they refer to the infamous &#8220;loop&#8221;&#8230; But where is it, what is it, and how do you find it? I&#8217;m going to run through &#8220;the loop&#8221; what it does and how to find it in your WordPress theme.</p>
<p><span id="more-235"></span></p>
<p><strong>What is it?</strong></p>
<p>To learn how to find the loop, it would be good to know what it does, and it&#8217;s purpose within a template. Loops are used in virtually all computer programming languages, it&#8217;s purpose it to repeat a set of tasks. Basically, you could code the same thing 10 times or use a loop to repeat the action 10 times. In WordPress, loops are used to get each blog article, or piece of information from the database, then read it out in HTML. This is how you see multiple articles presented on your blogs homepage without the code being in the template for each article. &#8220;The Loop&#8221; will generally only be on the <em>index.php</em> page of your template.</p>
<p><strong>Finding the loop&#8230;</strong></p>
<p>Every PHP programmer will program their template differently which means each loop is different. to combat this I&#8217;m going to attempt to arm you with the basics of PHP so that you can understand the workings of the code and find &#8220;the loop&#8221;.</p>
<p><strong>Reading PHP</strong></p>
<p>Lets start with separating the PHP from the HTML. It is important to recognise the difference between PHP and HTML, PHP being what&#8217;s known as a &#8220;Server-Side Language&#8221; and HTML being a &#8220;Client-Side Language&#8221;. PHP is run on the server, hence the term &#8220;Server-Side Language&#8221; &#8211; All PHP scripts are read by the server before any information is sent to the web browser for the &#8220;client&#8221; to see. HTML being &#8220;Client-Side&#8221; is read by the web browser on the clients side &#8211; using their computer resources, not the servers. &#8220;Server-Side&#8221; scripting will always be processed first on the server, then the information will be sent the &#8220;Client-Side&#8221; so it can present the information to you.</p>
<p>Finding the PHP is fairly easy. All PHP is enclosed between either of the following:</p>
<pre><code>&lt;?php
	// PHP script here
?&gt;
</code>
<code>&lt;?
	// PHP script here
?&gt;
</code></pre>
<p>Both &lt;? php &amp; &lt;? do the exact same thing, just one is shorter than the other. ?&gt; will signal the end of a set of PHP scripting. So to find &#8220;the loop&#8221; you need to look within these.</p>
<p><strong>The start of the loop!</strong></p>
<p>The proper term for the most commonly used &#8220;loop&#8221; in WordPress is a &#8220;while loop&#8221;. The most commonly used  &#8220;while&#8221; codes will look like this:</p>
<p><code>while (have_posts()) : the_post();</code><br />
<code>if (have_posts()) : while (have_posts()) : the_post();</code></p>
<p>This is the start of &#8220;the loop&#8221;. It&#8217;s effectively telling the server &#8220;while there is new posts, do the following&#8221;. Not too different to standard English. The &#8220;if&#8221; on the second code is first asking &#8220;if there is a post, then do the while loop&#8221;.</p>
<p>It might be an idea to mark this spot for reference, so after the PHP script put a HTML comment like follows:</p>
<pre><code>&lt;?php while (have_posts()) : the_post(); ?&gt;
	&lt;!-- Start of the loop --&gt;
</code></pre>
<p><strong>The end of the loop!</strong></p>
<p>Now we&#8217;ve found the start of &#8220;the loop&#8221;, we need to find the end. This should always look as follows:</p>
<p><code>endwhile;</code></p>
<p>This will end the content that is being &#8220;looped&#8221;.</p>
<p>Lets mark the end of &#8220;the loop&#8221; with a HTML comment once more but this time above the PHP script like follows:</p>
<pre><code>	&lt;!-- End of the loop --&gt;
&lt;?php endwhile; ?&gt;
</code></pre>
<p>Okay so now you have found &#8220;the loop&#8221; the content within where you have marked is inside the loop, anything outside this script area is &#8220;outside the loop&#8221;. HTML within this loop will behave as normal HTML however it is just repeated multiple times.</p>
<p>So there we have it &#8211; finding &#8220;the loop&#8221; in a nutshell. &#8220;The loop&#8221; will generally only be on the home page and there should only be one loop, if you find multiple loops, use your HTML knowledge to find which is the correct loop for what you are trying to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/06/tutorial-finding-working-with-the-loop-in-wordpress-templates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finding the X &amp; Y coordinates of an element relative to the entire page using Javascript</title>
		<link>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 08:16:48 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=187</guid>
		<description><![CDATA[It&#8217;s really easy to get the position of an element relative to it&#8217;s parent element, but what if you wanted to get it&#8217;s position relative to the entire page (viewport)? There&#8217;s no javascript call to do this, but here is a function to get the elements x &#38; y coordinates. If you use the prototype [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s really easy to get the position of an element relative to it&#8217;s parent element, but what if you wanted to get it&#8217;s position relative to the entire page (viewport)? There&#8217;s no javascript call to do this, but here is a function to get the elements x &amp; y coordinates.</p>
<p><span id="more-187"></span></p>
<p>If you use the <a href="http://www.prototypejs.org" target="_blank">prototype javascript framework</a> there is a call built in! Handy&#8230;</p>
<p><strong>Here&#8217;s the code for Prototype users:</strong></p>
<p><code>var pos = $("<em>elementID</em>").viewportOffset();<br />
var x = pos[0];<br />
var y = pos[1];</code></p>
<p>Nice and easy&#8230;</p>
<p>For those of you who <strong>don&#8217;t</strong> use prototype, below is a function you can use to get the X &amp; Y coordinates relative to the page (viewport).</p>
<p><strong>The Function:</strong></p>
<pre><code>function viewportOffset(forElement) {
	var valueT = 0, valueL = 0;&lt;
	var element = document.getElementById(forElement);
	do {
		valueT += element.offsetTop  || 0;
		valueL += element.offsetLeft || 0;
		if (element.offsetParent == document.body) break;
	} while (element = element.offsetParent);
	element = forElement;
	do {
		if (element.tagName == 'BODY') {
			valueT -= element.scrollTop  || 0;
			valueL -= element.scrollLeft || 0;
		}
	} while (element = element.parentNode);
	return [valueL, valueT];
}</code></pre>
<p><em>This is a modified function from the </em><em><a href="http://www.prototypejs.org" target="_blank">prototype framework</a></em>.</p>
<p><strong>Calling The Function:</strong></p>
<p><code>var pos = viewportOffset("<em>elementID</em>");<br />
var x = pos[0];<br />
var y = pos[1];</code></p>
<p>I tried several of the functions on various blogs etc none of them seemed to return anything but 0 in Safari. The above has been tested and works in the latest versions Safari, Firefox, IE and Opera.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/06/tip-getting-the-x-y-coordinates-of-an-element-relative-to-the-entire-page-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using variables in Javascript&#8217;s replace function.</title>
		<link>http://www.thewebdevelopmentblog.com/2009/02/tip-using-variables-in-javascripts-replace-function/</link>
		<comments>http://www.thewebdevelopmentblog.com/2009/02/tip-using-variables-in-javascripts-replace-function/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 11:21:04 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=176</guid>
		<description><![CDATA[Today I hit a snag when I wanted to use a variable in Javascript&#8217;s replace function. Of course Javascript isn&#8217;t as easy as PHP as in order to replace content from a string or variable it has to be a regular expression. Luckily there is an easy enough way to convert your variable into a [...]]]></description>
			<content:encoded><![CDATA[<p>Today I hit a snag when I wanted to use a variable in Javascript&#8217;s replace function. Of course Javascript isn&#8217;t as easy as PHP as in order to replace content from a string or variable it has to be a regular expression. Luckily there is an easy enough way to convert your variable into a regular expression perfect for sending through the javascript replace function.</p>
<p><span id="more-176"></span></p>
<p><strong>The Solution</strong></p>
<p>Use javascripts RegExp to convert your variable before parsing it through the replace function.</p>
<p><code>var regex = new RegExp(<em>yourvariable</em>, “g”);<br />
return <em>yourstring</em>.replace(regex, “<em>replaced</em>”);</code></p>
<p>It&#8217;s quite an easy solution, no major hair pulling involved!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2009/02/tip-using-variables-in-javascripts-replace-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New version of gzip for Javascript &amp; CSS now available</title>
		<link>http://www.thewebdevelopmentblog.com/2008/12/script-new-version-of-gzip-for-javascript-css-now-available/</link>
		<comments>http://www.thewebdevelopmentblog.com/2008/12/script-new-version-of-gzip-for-javascript-css-now-available/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 05:04:41 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[Gzip]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=143</guid>
		<description><![CDATA[I&#8217;ve released version 1.1.1 of my gzip php script for Javascript and CSS which is a minor updates and adds a few handy new features. You can get the latest version of the script here. You can read the release notes here.]]></description>
			<content:encoded><![CDATA[<div>
<p>I&#8217;ve released version 1.1.1 of my gzip php script for Javascript and CSS which is a minor updates and adds a few handy new features. You can get the latest version of the script <a title="Go to the Gzip compression blog post" href="http://thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/" target="_self">here</a>. You can read the <a title="View the gzip compression release notes" href="http://thewebdevelopmentblog.com/examples/gzip/gzip/releasenotes.txt" target="_blank">release notes here</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2008/12/script-new-version-of-gzip-for-javascript-css-now-available/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gzip compression script for javascript and CSS updated</title>
		<link>http://www.thewebdevelopmentblog.com/2008/11/tipscript-gzip-compression-script-for-javascript-and-css-updated/</link>
		<comments>http://www.thewebdevelopmentblog.com/2008/11/tipscript-gzip-compression-script-for-javascript-and-css-updated/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 09:21:11 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[Gzip]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=140</guid>
		<description><![CDATA[Today I&#8217;ve updated my gzip compression for javascript and CSS script to fix a security flaw. If you&#8217;re using V1.0 I advise you update to V1.1 which is available here. You can read the release notes here.]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve updated my gzip compression for javascript and CSS script to fix a security flaw. If you&#8217;re using V1.0 I advise you update to V1.1 which is available <a title="Go to the Gzip compression blog post" href="http://thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/" target="_self">here</a>. You can read the <a title="View the gzip compression release notes" href="http://thewebdevelopmentblog.com/examples/gzip/gzip/releasenotes.txt" target="_blank">release notes here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2008/11/tipscript-gzip-compression-script-for-javascript-and-css-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript benchmarking, who to believe?</title>
		<link>http://www.thewebdevelopmentblog.com/2008/10/browsers-javascript-benchmarking-who-to-believe/</link>
		<comments>http://www.thewebdevelopmentblog.com/2008/10/browsers-javascript-benchmarking-who-to-believe/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 08:46:22 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Benchmarking]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=98</guid>
		<description><![CDATA[There is no shortage of Javascript Benchmark tests out there. Yet lately, it&#8217;s started to get a bit shaky on which browser is faster than the other, and some results don&#8217;t seem to match real life use. The only thing anyone can agree on is that Internet Explorer is the worst. So what do we [...]]]></description>
			<content:encoded><![CDATA[<p>There is no shortage of Javascript Benchmark tests out there. Yet lately, it&#8217;s started to get a bit shaky on which browser is faster than the other, and some results don&#8217;t seem to match real life use. The only thing anyone can agree on is that Internet Explorer is the worst. So what do we believe?</p>
<p><span id="more-98"></span>Browsing around I looked at various benchmarking results, some old, some recent to see how the browsers were fairing. Only they don&#8217;t seem to agree with each other, and using some in real life, browser that are supposed to be speedy are actually visually slower than the ones that are supposedly slower. None of it makes sense. On my search I found a few speed testing tools I could use myself, yet again, it didn&#8217;t add up.</p>
<p>One test I tried was <a title="Go to the V8 benchmarking tool on Google." href="http://code.google.com/apis/v8/run.html" target="_blank">benchmarking tool posted on Google</a>. In the test apparently bigger is better&#8230; My tests came up as follow&#8230;</p>
<blockquote><p>Safari 3 &#8211; 190</p>
<p>Opera 9.6 &#8211; 199</p>
<p>Firefox 3 &#8211; 208</p>
<p>Chromium &#8211; 2297 (<a title="Download Cross-over Chromium" href="http://www.codeweavers.com/services/ports/chromium/" target="_blank">Chromium</a> is a port of <a title="Download Google Chrome for Windows" href="http://www.google.com/chrome" target="_blank">Google Chrome Beta</a> for Mac)</p></blockquote>
<p>Given these results you&#8217;d think that Chromium was lightning fast compared to the others. In real use on a Javascript intensive site of mine, Chromium choked as did Firefox 3, however Safari and Opera were blazing fast. So I re-read the site because I was thinking maybe I misread. I didn&#8217;t, it still said bigger is better.</p>
<p>It&#8217;s got me thinking why? I studied the tests for about 2 minutes then I spotted a pattern in the ones that seemed to perform better. The test on Google ran 5 tests through 5 different test engine of different script sizes. Generally the browsers varied at speeds in each test, but there was some strange happenings with the browsers that scored highest. They didn&#8217;t seem to score so high in the big tests in comparison to the small test scripts. Here are my findings&#8230;.</p>
<blockquote><p>Safari 3 &#8211; 121 + 411 = 3.4x better</p>
<p>Opera 9.6 &#8211; 121 + 571 = 4.7x</p>
<p>Firefox 3 &#8211; 193 + 253 = 1.3x</p>
<p>Chromium &#8211; 2561 + 2984 = 1.16x</p></blockquote>
<p>What this shows is even though the browsers may be faster at little jobs, once you start using intense Javascript some browsers tend to slow where as the ones that appear quicker in real use are the ones who&#8217;s performance increased compared to the initial shorter scripts. My theory is Safari and Opera are actually faster at more intense scripting, compared to Firefox and Chromium which are better at less intense scripts.</p>
<p>So after all that I think it&#8217;s safe to say different browsers perform differently depending on what the Javascript task it&#8217;s performing. If it benchmarks better it won&#8217;t necessarily mean better performance on your particular script. If all else fails do some tests!</p>
<p><strong>NOTE: </strong>These tests were run on an iMac 2.8GHz Intel Core 2 Duo with 2GB SDRAM running Mac OS X 10.5.5 with various tabs open in each browser. Test result will vary on different systems. Chromium shouldn&#8217;t be used as a benchmark for Google Chrome as the port is significantly slower than the real version of Google Chrome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2008/10/browsers-javascript-benchmarking-who-to-believe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

