/*http://mondomaine.tld/?name=geoffrey
http://mondomaine.tld/?name=geoffrey&age=42
*/
function $_GET(param) {
var vars = {};
window.location.href.replace(
/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
function( m, key, value ) { // callback
vars[key] = value !== undefined ? value : '';
}
);
if ( param ) {
return vars[param] ? vars[param] : null;
}
return vars;
}
/*
Avec cette fonction JavaScript, vous avez deux utilisations différentes :
var name = $_GET('name'),
age = $_GET('age');
ou, méthode plus performante :
var $_GET = $_GET(),
name = $_GET['name'],
age = $_GET['age'];
*/