<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Read URL GET variables with JavaScript</title>
	<atom:link href="http://papermashup.com/read-url-get-variables-withjavascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://papermashup.com/read-url-get-variables-withjavascript/</link>
	<description>Ashley Ford :: CSS &#124; PHP &#124; JavaScript</description>
	<lastBuildDate>Wed, 28 Jul 2010 15:36:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Ashley</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-2793</link>
		<dc:creator>Ashley</dc:creator>
		<pubDate>Tue, 06 Jul 2010 22:28:30 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-2793</guid>
		<description>Hi Jon,

No Problem, you simply need to add both code snippets between script tags within you page head then save your page and upload it to your web server and visit the page. at first you wont see anything but then add at the end of the URL in your browser ?id=1234 then you should see 1234 alerted. I&#039;ve made a typo in the code snippet. the alerts should be alert(first); alert(second); the &#039;id&#039; and &#039;page&#039; can be any get variable that you want to pick up with javascript.

Hope that helps

Ashley</description>
		<content:encoded><![CDATA[<p>Hi Jon,</p>
<p>No Problem, you simply need to add both code snippets between script tags within you page head then save your page and upload it to your web server and visit the page. at first you wont see anything but then add at the end of the URL in your browser ?id=1234 then you should see 1234 alerted. I&#8217;ve made a typo in the code snippet. the alerts should be alert(first); alert(second); the &#8216;id&#8217; and &#8216;page&#8217; can be any get variable that you want to pick up with javascript.</p>
<p>Hope that helps</p>
<p>Ashley</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jon mortimer</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-2767</link>
		<dc:creator>jon mortimer</dc:creator>
		<pubDate>Sat, 03 Jul 2010 12:20:05 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-2767</guid>
		<description>Sorry for this post since it is a year old but I have a question. I am a faily newbie and appreciate any assistance. Firstly, where do I place this code? I&#039;m assuming I can put it into my html file within javascript brackets. I&#039;ve done that -- how do I use the variable though, since it is outside the &quot;function&quot;? Obviously if I just place the variables on an html page it will just display as text.</description>
		<content:encoded><![CDATA[<p>Sorry for this post since it is a year old but I have a question. I am a faily newbie and appreciate any assistance. Firstly, where do I place this code? I&#8217;m assuming I can put it into my html file within javascript brackets. I&#8217;ve done that &#8212; how do I use the variable though, since it is outside the &#8220;function&#8221;? Obviously if I just place the variables on an html page it will just display as text.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris M</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-2311</link>
		<dc:creator>Chris M</dc:creator>
		<pubDate>Thu, 11 Mar 2010 12:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-2311</guid>
		<description>Anyone looking to read the #Anchor from a url using javascript such as index.html#welcome try this.

 var urlanchor = self.document.location.hash.substring(1);</description>
		<content:encoded><![CDATA[<p>Anyone looking to read the #Anchor from a url using javascript such as index.html#welcome try this.</p>
<p> var urlanchor = self.document.location.hash.substring(1);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-2199</link>
		<dc:creator>Ashley</dc:creator>
		<pubDate>Wed, 10 Feb 2010 08:53:47 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-2199</guid>
		<description>@molokoloco, Thanks!</description>
		<content:encoded><![CDATA[<p>@molokoloco, Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: molokoloco</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-2190</link>
		<dc:creator>molokoloco</dc:creator>
		<pubDate>Tue, 09 Feb 2010 13:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-2190</guid>
		<description>Ok, thank, great regex :)
here the code to integrate with jQuery :)

&lt;code&gt;
	$.extend({
		getUrlVars: function() {
			var vars = {};
			var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi, function(m,key,value) { vars[key] = value; });
			return vars;
		}
	});
       // var name = $.getUrlVars()[&#039;name&#039;];
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Ok, thank, great regex <img src='http://papermashup.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
here the code to integrate with jQuery <img src='http://papermashup.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
	$.extend({<br />
		getUrlVars: function() {<br />
			var vars = {};<br />
			var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi, function(m,key,value) { vars[key] = value; });<br />
			return vars;<br />
		}<br />
	});<br />
       // var name = $.getUrlVars()['name'];<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-1942</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 29 Dec 2009 08:00:32 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-1942</guid>
		<description>thanks for the code</description>
		<content:encoded><![CDATA[<p>thanks for the code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: <fb:name linked="false" useyou="false" uid="772934751">Serdar Alten Şimşek</fb:name></title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-1793</link>
		<dc:creator><fb:name linked="false" useyou="false" uid="772934751">Serdar Alten Şimşek</fb:name></dc:creator>
		<pubDate>Sun, 06 Dec 2009 10:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-1793</guid>
		<description>thank you</description>
		<content:encoded><![CDATA[<p>thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevej</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-1665</link>
		<dc:creator>stevej</dc:creator>
		<pubDate>Fri, 30 Oct 2009 16:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-1665</guid>
		<description>function getUrlVars(url) {
	var vars = {};
    var url = url? url.toString().split(&#039;?&#039;).pop()
                 : window.location.search.slice(1);
    url.replace(
	       /([^=&amp;]+)=([^&amp;]*)/gi, 
	       function(m,key,value) {
        	   key = unescape(key);
        	   if (key) {
        	     value = unescape(value);
        	     if (key in vars) {
        	       if (vars[key] instanceof Array)
        	           vars[key].push(value);
        	       else
        	           vars[key] = [vars[key], value];
        	     } else
        	       vars[key] = value;
        	   }
        	});
	return vars;
}</description>
		<content:encoded><![CDATA[<p>function getUrlVars(url) {<br />
	var vars = {};<br />
    var url = url? url.toString().split(&#8216;?&#8217;).pop()<br />
                 : window.location.search.slice(1);<br />
    url.replace(<br />
	       /([^=&amp;]+)=([^&amp;]*)/gi,<br />
	       function(m,key,value) {<br />
        	   key = unescape(key);<br />
        	   if (key) {<br />
        	     value = unescape(value);<br />
        	     if (key in vars) {<br />
        	       if (vars[key] instanceof Array)<br />
        	           vars[key].push(value);<br />
        	       else<br />
        	           vars[key] = [vars[key], value];<br />
        	     } else<br />
        	       vars[key] = value;<br />
        	   }<br />
        	});<br />
	return vars;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stevej</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-1664</link>
		<dc:creator>stevej</dc:creator>
		<pubDate>Fri, 30 Oct 2009 15:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-1664</guid>
		<description>If a key repeats (e.g. checkboxes), only the value of the last pair will be available.</description>
		<content:encoded><![CDATA[<p>If a key repeats (e.g. checkboxes), only the value of the last pair will be available.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley</title>
		<link>http://papermashup.com/read-url-get-variables-withjavascript/comment-page-1/#comment-1663</link>
		<dc:creator>Ashley</dc:creator>
		<pubDate>Fri, 30 Oct 2009 10:07:39 +0000</pubDate>
		<guid isPermaLink="false">http://papermashup.com/?p=1186#comment-1663</guid>
		<description>@jared thanks for pointing that out, quite a few people contacted me about that. My mistake see the updated post above. ;)</description>
		<content:encoded><![CDATA[<p>@jared thanks for pointing that out, quite a few people contacted me about that. My mistake see the updated post above. <img src='http://papermashup.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
