Return to Snippet

Revision: 22653
at January 18, 2010 16:51 by geekyjohn


Initial Code
$.urlParam = function(name){
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
	if (!results) { return 0; }
	return results[1] || 0;
}

Initial URL


Initial Description
This is an improvement on http://snipplr.com/view/11583/retrieve-url-params-with-jquery/
I found IE wasn't liking the results[1] when no param was set. This fixes that issue.

Initial Title
Get URL Parameters with jQuery | Improved

Initial Tags
url, javascript, jquery

Initial Language
jQuery