Return to Snippet

Revision: 17920
at September 16, 2009 20:16 by the_coder


Initial Code
function getUrlVars() {
	var map = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		map[key] = value;
	});
	return map;
}

Initial URL


Initial Description
Read a page's GET URL variables and return them as an "associative array."

Calling the function while at `example.html?foo=asdf&bar=jkls` sets `map['foo']='asdf'` and `map['bar']='jkls'`

Initial Title
Get Url Parameters

Initial Tags
regex, url

Initial Language
JavaScript