Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

claudemircruz

Como criar um script cross-browser

Recommended Posts

Olá pessoal estou tentando criar uma intranet mais estou com problemas, pois, um javascript funcionana num brouser e no outro não.

 

Como programar para funcionar pelomenos no IE, Mozzilla, konqueror, Firefox ao mesmo tempo.

Sito o exemplo abaixo, que ralei pra fazer e não funciona no Firefox e preciso fazer que funciona. São dois selects onde o segundo mostrar apenas os ítens referente ao grupo selecionado no primeiro. E depois tem o código de digitar somente números que não funciona em todos....

 

<script language="javascript1.4" type="text/javascript">	function js_removeChar2(obj) { 	var src = new String(obj.value); 	var tar = new String(); 	var i, len=src.length; 	for (i=0; i < len; i++) { 		if (src.charAt(i) == '/') 			tar += ''; 		else 			tar += src.charAt(i); 	} 	obj.value = tar;    }    function js_numberCheck(str) { 	if (isNaN(str))	return false; 	else return true;    }    function onlyNumber()   {		if((event.keyCode<48)||(event.keyCode>57))		event.returnValue=false;   }   function Verifica(event){var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;var caract = new RegExp(/^[0-9 ]+$/i);var caract = caract.test(String.fromCharCode(keyCode));//------------------------if(!caract){alert("Caracter inválido: " +String.fromCharCode(keyCode));keyCode=0;return false;}}  </script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

EPA !!??? Me esqueci de postar os do combo..

 

AAlves se puder me ajudar eu agradeceria...

 

 

<script language="JavaScript"><!--var NS4 = (document.layers) ? true : false;var IE4 = (document.all) ? true : false;matcresp=Array();matoresp=Array();matdresp=Array();matcresp[0]='1		 '; matoresp[0]='1		 '; matdresp[0]='Moveis/Escritórios'; matcresp[1]='2		 '; matoresp[1]='1		 '; matdresp[1]='Informática'; matcresp[2]='3		 '; matoresp[2]='1		 '; matdresp[2]='Equipamento Médico'; matcresp[3]='4		 '; matoresp[3]='1		 '; matdresp[3]='Equipamento Consulta Médico';matcresp[4]='5		 '; matoresp[4]='1		 '; matdresp[4]='Equipamento Odontológico'; matcresp[5]='6		 '; matoresp[5]='1		 '; matdresp[5]='Aparelhos de TV';matcresp[6]='7		 '; matoresp[6]='1		 '; matdresp[6]='Aparelho de SOM'; matcresp[7]='8		 '; matoresp[7]='1		 '; matdresp[7]='Video Cassete/DVD'; matcresp[8]='9		 '; matoresp[8]='1		 '; matdresp[8]='Aparelhos Elétricos'; matcresp[9]='10		'; matoresp[9]='1		 '; matdresp[9]='Outros Patrimoniados'; matcresp[10]='11		'; matoresp[10]='2		 '; matdresp[10]='Material de Escritório'; matcresp[11]='12		'; matoresp[11]='2		 '; matdresp[11]='Material Hospitalar'; matcresp[12]='13		'; matoresp[12]='2		 '; matdresp[12]='Material de Enfermagem'; matcresp[13]='14		'; matoresp[13]='2		 '; matdresp[13]='Material de Limpeza'; matcresp[14]='15		'; matoresp[14]='2		 '; matdresp[14]='Impressos'; matcresp[15]='16		'; matoresp[15]='2		 '; matdresp[15]='Material de Laboratório'; matcresp[16]='17		'; matoresp[16]='2		 '; matdresp[16]='Material Frente de Trabalho'; matcresp[17]='18		'; matoresp[17]='2		 '; matdresp[17]='Material Vigilância'; matcresp[18]='19		'; matoresp[18]='2		 '; matdresp[18]='Material DST/AIDS'; matcresp[19]='20		'; matoresp[19]='3		 '; matdresp[19]='Capsula'; matcresp[20]='21		'; matoresp[20]='3		 '; matdresp[20]='Comprimidos'; matcresp[21]='22		'; matoresp[21]='3		 '; matdresp[21]='Frascos'; matcresp[22]='23		'; matoresp[22]='3		 '; matdresp[22]='Bisnaga/Creme'; matcresp[23]='24		'; matoresp[23]='3		 '; matdresp[23]='Bisnaga/Pomada'; matcresp[24]='25		'; matoresp[24]='3		 '; matdresp[24]='Gel'; matcresp[25]='26		'; matoresp[25]='3		 '; matdresp[25]='Solução'; matcresp[26]='27		'; matoresp[26]='3		 '; matdresp[26]='Xarope'; matcresp[27]='28		'; matoresp[27]='3		 '; matdresp[27]='FURP';matcresp[28]='29		'; matoresp[28]='3		 '; matdresp[28]='Solução Nasal'; matcresp[29]='30		'; matoresp[29]='3		 '; matdresp[29]='Auto Custo'; matcresp[30]='31		'; matoresp[30]='3		 '; matdresp[30]='Medicamento Controlado';matoresp[31]='NULO'; function addOption(theForm,valor,numval){	if (NS4)	{		addOptionNS(theForm,valor,numval);	}	else if (IE4)	{		addOptionIE(theForm,valor,numval);	}}// (1) addOptionNS(theForm)function addOptionNS(theForm,valor,numval){	var newOpt  = new Option(valor,numval);	var selLength = theForm.responsavel.length;	theForm.responsavel.options[selLength] = newOpt;	history.go(0);}// (2) addOptionIE(theForm)function addOptionIE(theForm,valor,numval){	var newOpt = document.createElement("OPTION");	newOpt.text=valor;	newOpt.value=numval;	theForm.responsavel.add(newOpt);}function deleteOption(theForm){		if (NS4)	{		deleteOptionNS(theForm);	}	else if (IE4)	{		deleteOptionIE(theForm);	}	}// (3) deleteOptionNS(theForm)function deleteOptionNS(theForm){	var selLength = theForm.responsavel.length;	if (selLength>0)	{		theForm.responsavel.options[selLength-1]=null;		history.go(0);	}}// (4) deleteOptionIE(theForm)function deleteOptionIE(theForm){	var selLength = theForm.responsavel.length;	if (selLength>0)	{		theForm.responsavel.remove(selLength-1);	}}function opcoes(theForm){	var i = 0;	while((theForm.responsavel.length > 0))	{		deleteOption(theForm);	}		while((matoresp[i] != 'NULO'))	{		if (matoresp[i]==theForm.filtro.value)		{			addOption(theForm,matdresp[i],matcresp[i]);		}		i = i + 1;	}}//--></script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.