galera, como eu recupero um valor passado por get. utilizando somente javascript?
Recuperar Valor Passado Por Get
Started By victormangia, 03/07/2006, 16:52
1 reply to this topic
#2
Posted 03/07/2006, 17:05
document.location.search
O problema é que ele retorna tudo que vem depois de ?. Para resolver isso, fazemos assim:
HTML
<script type="text/javascript">
var getVars, tGet = [];
getVars = substr(document.location.search, 1);
getVars = getVars.split('&');
var t, n, tmpV;
for (t=0,n=getVars.length;t<n;t++)
{
tmpV=getVars[t].split('='); tGet[tmpV[0]]=tmpV[1];
}
</script>
O problema é que ele retorna tudo que vem depois de ?. Para resolver isso, fazemos assim:
HTML
<script type="text/javascript">
var getVars, tGet = [];
getVars = substr(document.location.search, 1);
getVars = getVars.split('&');
var t, n, tmpV;
for (t=0,n=getVars.length;t<n;t++)
{
tmpV=getVars[t].split('='); tGet[tmpV[0]]=tmpV[1];
}
</script>
Raphael prefere :
Mozilla/5.0 => Tema :Noia 2.0 (eXtreme) | Linux Mandriva
Linguagens :
PHP | ASP | VB | JavaScript | Dhtml |
Banco de dados :
ODBC | Mysql | SQL Server | Oracle 10g
To aprendendo :
Java | Ajax | Web 2.0
Ferramentas :
PL - SQL | Mysql Front | PHP editor | PhotoShop | Mysql Adminstrator
Mozilla/5.0 => Tema :Noia 2.0 (eXtreme) | Linux Mandriva
Linguagens :
PHP | ASP | VB | JavaScript | Dhtml |
Banco de dados :
ODBC | Mysql | SQL Server | Oracle 10g
To aprendendo :
Java | Ajax | Web 2.0
Ferramentas :
PL - SQL | Mysql Front | PHP editor | PhotoShop | Mysql Adminstrator
0 user(s) are reading this topic
0 membro(s), 0 visitante(s) e 0 membros anônimo(s)