Deu branco em receber parametro em outra pagina!

1 resposta
P

Olá,

uma duvida ao chamar a url abaixo como recebo no html index4.html

o parametro temporario e estou usando somente html…

Como consigo ler esse parametro ???

alguém pode me ajudar…

abs

file:///C:/TEMP/pagina/index4.html?temporario=1&nom_usu=&cod_nvl=&cod_fil=

1 Resposta

P

use este script no html que irá receber os parâmetros:

function getParametro( id ){
	valor = "";
	url = window.location.href;
	
	posInit = url.indexOf( "?" );
	
	if( posInit == -1 )
		return null;
		
	posId = url.indexOf( "?" + id + "=", posInit-1 );
	
	if( posId == -1 ){
		posId = url.indexOf( "&" + id + "=", posInit-1 );
	}
	
	if( posId == null ){
		alert("Erro");
		return;
	}
	
	posE = url.indexOf( "&", posId + 1 );
	
	if( posE == -1 ){
		valor = url.slice( posId + id.length + 2, url.length );
	}
	else{
		valor = url.slice( posId + id.length + 2, posE );
	}
	return valor;
}


function encodeURL( url ){
	posId = window.location.href.indexOf( "?" );
	
	if( posId != -1 )
		return url + window.location.href.slice( posId , window.location.href.length )+"";
	else
		return url+"";
}

para obter o parâmetro use:

value = getParametro( 'temporario' );
Criado 28 de agosto de 2009
Ultima resposta 28 de ago. de 2009
Respostas 1
Participantes 2