Return to Snippet

Revision: 11192
at January 27, 2009 17:20 by garside


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

// example.com?someparam=name&otherparam=8&id=6
$.urlParam('someparam'); // name
$.urlParam('id');        // 6
$.urlParam('notavar');   // null

Initial URL

                                

Initial Description

                                

Initial Title
Retrieve URL params with jQuery

Initial Tags
url, jquery

Initial Language
jQuery