Return to Snippet

Revision: 51769
at October 4, 2011 04:07 by vaibhav011286


Initial Code
function $_GET(a) {
	return (a = location.search.match(RegExp("[?&]" + a + "=([^&]*)(&?)", "i"))) ? a[1] : a
}

// example, if browser's url was like:
//     http://www.google.co.in/search?q=web&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
// then you can get the value of any parameter like: alert($_GET('rls'));
// returns org.mozilla:en-US:official as an alert

Initial URL


Initial Description


Initial Title
$_GET() function to get any url parameter in javascript

Initial Tags


Initial Language
JavaScript