Apr-7-2008
Javascript’s function that fetch URL parameters. (PHP’s $_GET emulator)
Here’s my javascript function that fetch URL parameters (kinda PHP’s $_GET emulator).
function URL_param(param){
// this condition suppress error
if(location.href.match(param+'=')) return location.href.toString().split(param+'=')[1].split(’&’)[0];
}
eg.
URL:
http://www.zhannar.com/?param1=value1¶m2=value2
JS script:
alert(URL_param('param2'));
returns:
value2
Simple. ![]()
