User:Year2000Prob/$ GET.js

/* * PHP $_GET function for JavaScript * v1.0 by Gareth Nettle-Smythe * * Use: * Set the URL of your page to something like: http://www.example.org/foo.html?foo=moofoo * Then use this JavaScript code: var GET_example = $_GET["foo"]; * GET_Example should now return "moofoo". */

var $_GET = (function {	// in case this is not a DOM-based host	if (window) {		var a = new Array, b = window.location.search;		// in case there is no query string		if (b.indexOf("?") > -1) {			// in case there is an anchor after the query string			if (b.indexOf("#") > b.indexOf("?")) {				var c = b.substring(b.indexOf("?") + 1, b.indexOf("#")).split("&");			} else {				var c = b.substring(b.indexOf("?") + 1).split("&");			};			for (var e in c) {				var d = c[e].split("=");				a[d[0]] = d[1] || true; // return the defined argument, or true			}		}		return a;	} else {		return new Array;	} });