function getUrlParameters(parameter, staticURL, decode){
/*
Function: getUrlParameters
Descrição: Obtem o valor dos parâmetros da URL atual ou URL estática
Author: Tirumal
URL: www.code-tricks.com
*/
var currLocation = (staticURL.length)? staticURL : window.location.search,
parArr = currLocation.split("?")[1].split("&"),
returnBool = true;
for(var i = 0; i < parArr.length; i++){
parr = parArr[i].split("=");
if(parr[0] == parameter){
return (decode) ? decodeURIComponent(parr[1]) : parr[1];
returnBool = true;
}else{
returnBool = false;
}
}
if(!returnBool) return false;
}
This code has been taken from Code-tricks , you can use it from following form:
From the current window location:
var parametro1 = getUrlParameters("nomeDoParametro", "", true);
From a static url:
var parametro1 = getUrlParameters("usuario", "http://www.exemplo.com/default.html?usuario=pt", true);