Jump to content


Photo

Menu Horizontal


  • Faça o login para participar
1 reply to this topic

#1 gabriel_gm

gabriel_gm

    Novato no fórum

  • Usuários
  • 6 posts
  • Sexo:Não informado

Posted 09/02/2007, 16:42

falae galerinha!

então, não sou muito bom em javascript, comecei faz pouco tempo, então perdoem erros grosseiros!

o que eu quero fazer é um menu drop down, só que na horizontal =/

so far... é isso que eu consegui, ele abre, e fecha em 4 seg... o problema é que era pra ele fechar em 4 seg se o mouse nao estiver em cima do botão, nem do submenu!

agradeço desde já!

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nova pagina 1</title>
<script type="text/javascript">
var camada;
var timer;

function fecha(){	
  if(camada){ 		
  camada.style.visibility = "hidden";			  
  } else {
  alert("erro");
  }
}

function paraTempo(){	   		
  if(timer) clearTimeout(timer);  
}

function iniciaTempo(){
  timer = setTimeout("fecha()",4000);	
}

function IEHoverPseudo() {	
	var navItems = document.getElementById("tabela").getElementsByTagName("table")

	for (var i=0; i<navItems.length; i++) {		 
	  
	  navItems[i].onmouseover=function() { 				
			var camadas = this.getElementsByTagName("div");	  
		  for(var t=0; t<camadas.length; t++){	   	
			  if((camada) && (camada != camadas[t])) fecha();		  
			camada = camadas[t]; 	
			camadas[t].style.visibility = "visible"; 											
		  }		  
	  }
	  
	  navItems[i].onmouseout=function(){ 		  
		  var camadasB = this.getElementsByTagName("div");	 
		  for(var b=0; b<camadasB.length; b++){		  
			iniciaTempo();				
		  }	
	  }	   
	  
	  var camadasG = navItems[i].getElementsByTagName("div");	  
	  for(var g=0; g<camadasG.length; g++){	   			
		  camadasG[g].onmouseover=paraTempo;		  
		  camadasG[g].onmouseout=iniciaTempo;						
	  }   
		
	}

}
window.onload = IEHoverPseudo;
document.onclick = fecha;

</script>
<link rel="stylesheet" type="text/css" href="../stylesheet.css">
</head>

<body>

<table id="tabela" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="100">
<!-- comeco menu -->
<table border="0" cellpadding="0">
	<tr>
		<td class="topo" width="100" align="center">teste1</td>
	</tr>
	<tr>
		<td>
		<div style="background:#000000; visibility:hidden; border-style:solid; border-width:1px; position: absolute; width: 95px; height: 100px; z-index: 1" id="div1">
		&nbsp;</div>
		</td>
	</tr>
</table>
<!-- final menu -->
		</td>
		<td width="100">
<!-- comeco menu -->
<table border="0" cellpadding="0">
	<tr>
		<td class="topo" width="100" align="center">teste2</td>
	</tr>
	<tr>
		<td>
		<div style="background:#000000; visibility:hidden; border-style:solid; border-width:1px; position: absolute; width: 95px; height: 100px; z-index: 1" id="div2">
		&nbsp;</div>
		</td>
	</tr>
</table>
<!-- final menu -->		
		</td>
		<td width="100">
<!-- comeco menu -->
<table border="0" cellpadding="0">
	<tr>
		<td class="topo" width="100" align="center">teste3</td>
	</tr>
	<tr>
		<td>
		<div style="background:#000000; visibility:hidden; border-style:solid; border-width:1px; position: absolute; width: 95; height: 100px; z-index: 1" id="div3">
		&nbsp;</div>
		</td>
	</tr>
</table>
<!-- final menu -->		
		</td>
		<td width="100">&nbsp;</td>
		<td width="100">&nbsp;</td>
		<td width="100">&nbsp;</td>
		<td width="100">&nbsp;</td>
	</tr>
</table>

</body>

</html>

Edição feita por: gabriel_gm, 09/02/2007, 16:43.


#2 matt.cavotta

matt.cavotta

    Ativo

  • Usuários
  • 347 posts
  • Sexo:Masculino
  • Localidade:Campinas
  • Interesses:Desenvolvimento Web &amp; Programação

Posted 09/02/2007, 17:28

Olá. Para isso, faça um evento onmouseover sobre a div do submenu que chame mesma função que é chamada quando você fica com o mouse sobre o menu.
WebFórum - Equipe de Desenvolvimento - Estagiario

I'm back!
Posted Image Edgy Eft 7.04




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq