Return to Snippet

Revision: 45534
at May 3, 2011 17:46 by CJness


Initial Code
function get() 
{
	var get = new Object();
	var parameters = window.location.toString().split("?").pop().split("&");
	
	for (var i in parameters)
	{
		var parts = parameters[i].split("=");
		
		get[""+parts[0]+""] = parts[1];
	}
	
	return get;
}

//http://www.example.com/?foo=bar&bar=foo
var get = get();

console.log(get.foo) // returns "bar"

Initial URL

                                

Initial Description

                                

Initial Title
Javascript function $_GET

Initial Tags
javascript

Initial Language
JavaScript