Manejadores semánticos: asociar funciones a elementos de un menú.
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style type="text/css">
body{
background: linear-gradient(#CCC, #000 );
height:1000px;
}
nav{
width: auto;
height:auto;
margin: 0px auto;
/* border: 1px solid #FC0; */
background: linear-gradient(#ccc , #666);
border-radius: 30px;
}
nav ul{
width: 600px;
height: 35px;
margin: 0px auto;
}
nav ul li{
width: 150px;
float: left;
list-style: none;
color: #FC0; /* maíz */
font-size: 18px;
text-align: center;
}
nav ul li{
color: rgba(255,153,0,1);
font-size: 22px;
font-family: arial;
text-decoration: none;
text-shadow: 1px 1px 0px #000;
}
nav ul li:hover{
color: #FC0; /* maíz */
text-shadow: 1px 1px 0px #000;
}
</style>
<script type="text/javascript">
window.onload= function(){
var vectormenu = window.document.getElementsByClassName('menu');
for (i=0; i<vectormenu.length; i++ ){
switch (i){
case 0:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Home Page');
}
,false);
break;
case 1:
vectormenu.item(i).addEventListener('click',
function(){
alert('About Us');
}
,false);
break;
case 2:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Services');
}
,false);
break;
case 3:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Contact Us');
}
,false);
default:
//Sin código
}
}
}
</script>
</head>
<body>
<nav>
<ul>
<li class="menu">Home Page</li>
<li class="menu">About Us</li>
<li class="menu">Services</li>
<li class="menu">Contact Us</li>
</ul>
</nav>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style type="text/css">
body{
background: linear-gradient(#CCC, #000 );
height:1000px;
}
nav{
width: auto;
height:auto;
margin: 0px auto;
/* border: 1px solid #FC0; */
background: linear-gradient(#ccc , #666);
border-radius: 30px;
}
nav ul{
width: 600px;
height: 35px;
margin: 0px auto;
}
nav ul li{
width: 150px;
float: left;
list-style: none;
color: #FC0; /* maíz */
font-size: 18px;
text-align: center;
}
nav ul li{
color: rgba(255,153,0,1);
font-size: 22px;
font-family: arial;
text-decoration: none;
text-shadow: 1px 1px 0px #000;
}
nav ul li:hover{
color: #FC0; /* maíz */
text-shadow: 1px 1px 0px #000;
}
</style>
<script type="text/javascript">
window.onload= function(){
var vectormenu = window.document.getElementsByClassName('menu');
for (i=0; i<vectormenu.length; i++ ){
switch (i){
case 0:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Home Page');
}
,false);
break;
case 1:
vectormenu.item(i).addEventListener('click',
function(){
alert('About Us');
}
,false);
break;
case 2:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Services');
}
,false);
break;
case 3:
vectormenu.item(i).addEventListener('click',
function(){
alert('Opcion Contact Us');
}
,false);
default:
//Sin código
}
}
}
</script>
</head>
<body>
<nav>
<ul>
<li class="menu">Home Page</li>
<li class="menu">About Us</li>
<li class="menu">Services</li>
<li class="menu">Contact Us</li>
</ul>
</nav>
</body>
</html>