Programación en castellano
Inicio > Foros > Javascript > Menus desplegables
-Foros de debate

Javascript
Lista de foros | Lista de mensajes de este foro

Privacidad: Recuerde que la información escrita en los foros de programación es 100% pública y que su ip será registrada asociada a su mensaje. Si encuentra un mensaje fuera de lugar, por favor, notifiquelo para su revisión y eliminación.

Menus desplegables
Enviado por lr el día 24 de marzo de 2004

Hola a todos, ¿alguien podría decirme (preferiblemente con un código de ejemplo sencillo) cómo se hace un menu desplegable con desbordamiento?, por ejemplo como el que sale al pasar el raton sobre \'About Acer\' en http://global.acer.com/ Un saludo y muchas gracias a todos.

 
Re: Menus desplegables
Enviado por invitado el día 4 de abril de 2004

Hola.
No te gustara mejor este menu...?

Prueba en una pagina nueva, totalmente con el codigo en blanco, y luego modifica a tus necesidades.

Cuidado que los enlaces funcionan !!!

------------


<HTML>
<HEAD>

<TITLE>Static Slide Menu</TITLE>

<SCRIPT language="JavaScript">
<!--

/*
Copyright © MaXimuS 1999-2000, All Rights Reserved.
Site: http://www.absolutegb.com/maximus
E-mail: maximus@nsimail.com
*/

IE=document.all;
NS=document.layers;

/*
Configure menu styles below
NOTE: To edit the link colors, go to the STYLE tags and edit the ssm2Items colors
*/
hdrFontFamily="Verdana";
hdrFontSize="2";
hdrFontColor="white";
hdrBGColor="#666666";
linkFontFamily="Verdana";
linkFontSize="1";
linkBGColor="white";
linkOverBGColor="#CCCCCC";
linkTarget="_top";
YOffset=20;
staticYOffset=20;
menuBGColor="black";
menuIsStatic="yes";
menuHeader="Gamarod.com.ar"
menuWidth=150; // Must be a multiple of 5!
staticMode="advanced"
barBGColor="#333333";
barFontFamily="Verdana";
barFontSize="2";
barFontColor="white";
barText="Gamarod JavaScript";

function moveOut() {
if (window.cancel) {cancel="";}
if (window.moving2) {clearTimeout(moving2); moving2="";}
if ((IE && ssm2.style.pixelLeft<0)||(NS && document.ssm2.left<0)) {
if (IE) {ssm2.style.pixelLeft += (5%menuWidth);}
if (NS) {document.ssm2.left += (5%menuWidth);}
moving1 = setTimeout('moveOut()', 5)}
else {clearTimeout(moving1)}};
function moveBack() {
cancel = moveBack1()}
function moveBack1() {
if (window.moving1) {clearTimeout(moving1)}
if ((IE && ssm2.style.pixelLeft>(-menuWidth))||(NS && document.ssm2.left>(-140))) {
if (IE) {ssm2.style.pixelLeft -= (5%menuWidth);}
if (NS) {document.ssm2.left -= (5%menuWidth);}
moving2 = setTimeout('moveBack1()', 5)}
else {clearTimeout(moving2)}};

lastY = 0;
function makeStatic(mode) {
if (IE) {winY = document.body.scrollTop;var NM=ssm2.style}
if (NS) {winY = window.pageYOffset;var NM=document.ssm2}
if (mode=="smooth") {
if ((IE||NS) && winY!=lastY) {
smooth = .2 * (winY - lastY);
if(smooth > 0) smooth = Math.ceil(smooth);
else smooth = Math.floor(smooth);
if (IE) NM.pixelTop+=smooth;
if (NS) NM.top+=smooth;
lastY = lastY+smooth;}
setTimeout('makeStatic("smooth")', 1)}
else if (mode=="advanced") {
if ((IE||NS) && winY>YOffset-staticYOffset) {
if (IE) {NM.pixelTop=winY+staticYOffset}
if (NS) {NM.top=winY+staticYOffset}}
else {
if (IE) {NM.pixelTop=YOffset}
if (NS) {NM.top=YOffset-7}}
setTimeout('makeStatic("advanced")', 1)}}

function init() {
if (IE) {
ssm2.style.pixelLeft = -menuWidth;
ssm2.style.visibility = "visible"}
else if (NS) {
document.ssm2.left = -menuWidth;
document.ssm2.visibility = "show"}
else {alert('Choose either the "smooth" or "advanced" static modes!')}}

//-->
</SCRIPT>
<STYLE>
A.ssm2Items:link {color:black;text-decoration:none;}
A.ssm2Items:hover {color:black;text-decoration:none;}
A.ssm2Items:active {color:black;text-decoration:none;}
A.ssm2Items:visited {color:black;text-decoration:none;}
</STYLE>
</HEAD>
<BODY bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="init()">
<script language="JavaScript1.2">
if (IE) {document.write('<DIV ID="ssm2" style="visibility:hidden;Position : Absolute ;Left : 0px ;Top : '+YOffset+'px ;Z-Index : 20;width:1px" onmouseover="moveOut()" onmouseout="moveBack()">')}
if (NS) {document.write('<LAYER visibility="hide" top="'+YOffset+'" name="ssm2" bgcolor="'+menuBGColor+'" left="0" onmouseover="moveOut()" onmouseout="moveBack()">')}
tempBar=""
for (i=0;i<barText.length;i++) {
tempBar+=barText.substring(i, i+1)+"<BR>"}
document.write('<table border="0" cellpadding="0" cellspacing="1" width="'+(menuWidth+16+2)+'" bgcolor="'+menuBGColor+'"><tr><td bgcolor="'+hdrBGColor+'" WIDTH="'+menuWidth+'"> <font face="'+hdrFontFamily+'" Size="'+hdrFontSize+'" COLOR="'+hdrFontColor+'"><b>'+menuHeader+'</b></font></td><td align="center" rowspan="100" width="16" bgcolor="'+barBGColor+'"><p align="center"><font face="'+barFontFamily+'" Size="'+barFontSize+'" COLOR="'+barFontColor+'"><B>'+tempBar+'</B></font></p></TD></tr>')
function addItem(text, link, target) {
if (!target) {target=linkTarget}
document.write('<TR><TD BGCOLOR="'+linkBGColor+'" onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'"><ILAYER><LAYER onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'" WIDTH="100%"><FONT face="'+linkFontFamily+'" Size="'+linkFontSize+'"> <A HREF="'+link+'" target="'+target+'" CLASS="ssm2Items">'+text+'</LAYER></ILAYER></TD></TR>')}
function addHdr(text) {
document.write('<tr><td bgcolor="'+hdrBGColor+'" WIDTH="140"> <font face="'+hdrFontFamily+'" Size="'+hdrFontSize+'" COLOR="'+hdrFontColor+'"><b>'+text+'</b></font></td></tr>')}

//Only edit the script between HERE

addItem('Buscador de Rutinas', 'buscar.htm', '');
addItem('Foros de Discusión', '/foros/', '');
addItem('Lista de Correo', '/lista.htm', '');
addItem('Comentarios', '/comentarios.htm', '');
addItem('Contribución', '/contribuir.htm', '');
addItem('Firmar el Libro', '/firmar.htm', '');
addItem('Enlaces', '/enlaces.htm', '');
addItem('Agregar URL', 'agregar.htm', '');
addHdr('Todos los Script');
addItem('Alertas', 'alertas.htm', '');
addItem('Banner', 'banner.htm', '');
addItem('Cookies', 'cookies.htm', '');
addItem('Dhtml', 'dhtml.htm', '');
addItem('Enlaces', 'enlaces.htm', '');
addItem('Fecha', 'fecha.htm', '');
addItem('Imagen', 'imagen.htm', '');
addItem('Juegos', 'juegos.htm', '');
addItem('Midis', 'midis.htm', '');
addItem('Otras', 'otras.htm', '');
addItem('Prompt', 'prompt.htm', '');
addItem('Reloj', 'reloj.htm', '');
addItem('Seguridad', 'seguridad.htm', '');
addItem('Texto', 'texto.htm', '');
addItem('Ventana', 'ventana.htm', '');

// and HERE! No more!

document.write('<tr><td bgcolor="'+hdrBGColor+'"><font size="0" face="Arial"> </font></td></TR></table>')
if (IE) {document.write('</DIV>')}
if (NS) {document.write('</LAYER>')}
if ((IE||NS) && (menuIsStatic=="yes"&&staticMode)) {makeStatic(staticMode);}
</script>


<br><br><br>

</BODY>
</HTML>

 
Re: Re: Menus desplegables
Enviado por esnafrao el día 20 de abril de 2004

este menu esta muy bien, lo que no se como hacer para ponerlo en una pagina con dos marcos y al pulsar sobre cualquier enlace me lo habra en el marco principal y no en una pagina nueva en blanco, no se si me explico muy bien.

 

Re: Re: Menus desplegables
Enviado por invitado el día 20 de abril de 2004

este menu esta muy bien, lo que no se como hacer para ponerlo en una pagina con dos marcos y al pulsar sobre cualquier enlace me lo habra en el marco principal y no en una pagina nueva en blanco, no se si me explico muy bien.

 
Re: Re: Re: Menus desplegables
Enviado por Alfredo bielma lopez el día 21 de abril de 2004

Al utilizar frames asignale al segundo un nombre por ejemplo:
<frame src="pagina2.html" name="bien">
esto para la pagina que quiera que cambien.

bien, luego cuando pulsas en un hipervinculo del ejemplo anterior usa algo como esto:
<a href="pagina.html" target="bien">un texto </a>

Saludos de coatzacoalcos.

 
Re: Re: Re: Re: Menus desplegables
Enviado por esnafrao el día 21 de abril de 2004

gracias Alfredo, pero con este comando lo que estoy consiguiendo es que me habra una bentana nueva al pulsar cualquier enlace y no en el frame de la derecha que es lo que estoy buscando

 
Re: Re: Re: Re: Re: Menus desplegables
Enviado por ESNAFRAO el día 22 de abril de 2004

Anda que no nos complicamos la vida ni na por no mirar bien las cosas:
si te fijas sobre la linea 25: linkTarget, hay esta la solucion, solo hay que poner a donde quieres que te la abra y solucionado, despues de darle tantas vueltas.............

 




Re: Re: Menus desplegables
Enviado por Rashael el día 24 de abril de 2004

tu codigo esta muy bien diseñado sin embargo solo funciona bien en el ms internet explorer, a mi me agradaria que funcione en cualquier navegador, por ejemplo lo probe en el mozilla firefox pero no se oculta el menu; bueno yo encontre un menu desplegable que si funciona en el firefox:

Es este:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">

<!--

a.bi{

background-color:black;

color:#ffffff;

display:block;

font-family: MS Sans Serif,sans-serif;

font-size:8pt;

font-weight:bold;

padding:3px 3px 3px 3px;

text-decoration:none;

border-color: #225555 #000000 #000000 #225555;

border-style:solid;

border-width:2px;

}

a.bi:hover{

background-color:#f8f8f8;

color:black;

}

a.mi{

background-color:black;

color:#ffffff;

display:block;

font-family:MS Sans Serif,sans-serif;

font-size:8pt;

font-weight:bold;

padding: 2px 2px 2px 4px;

text-decoration:none;

}

a.mi:hover{

background-color:#f8f8f8;

color:black;

}

.mn{

background-color:black;

border-color: #225555 #000000 #000000 #225555;

border-style:solid;

border-width:2px;

z-index:100;

}

.sp{

BORDER-TOP:#000000 1px solid;

MARGIN:2px;

BORDER-BOTTOM:#225555 1px solid

}

//-->

</style>
<!--paste above inbetween your head tags-->

<!--Past below inbetween your body tags-->




<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="" content="text/html; charset=iso-8859-1">
</head>

<body>
<script language="JavaScript">

<!--//

var D6=window,Y7=document;function B8(){this.ver=navigator.appVersion;this.agent=navigator.userAgent;this.dom=Y7.getElementById?1:0;this.opera5=this.agent.indexOf("Opera 5")>-1;this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;this.ie4=(Y7.all && !this.dom && !this.opera5)?1:0;this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;this.ns6=(this.dom && parseInt(this.ver)>=5)?1:0;this.ns4=(Y7.layers && !this.dom)?1:0;this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);return this}bw=new B8();z=0;b=0;g="";if(bw.opera5||bw.ns6){b=2};if(bw.ie){g=" style='width: 100%'"}else{z=6}mt=70;ml=10;w=129;mh=23;mw=ml-w;k=0;mt=mt-z;p="<a class='mi'"+g+" href='";q="' title='";r="\"; return true' onmouseout='window.status=\"\"; return true'>";t="</a>";a="' onmouseover='window.status=\"";v="<div class=sp></div>"

m=new Array();n=new Array();s=new Array();sw=new Array();su=new Array();st=new Array()

m[0]='Portada';n[0]='#';sw[0]=120;su[0]='Portada';st[0]="";s[0]=""
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
m[1]='Galeria';n[1]='#';sw[1]=140;su[1]='Galeria';st[1]="";s[1]=""
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
m[2]='Opinion';n[2]='#';sw[2]=130;su[2]='Opinion';st[2]="";s[2]=""
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
+p+"page.html"+q+a+"Pagina 1"+r+"Pagina 1"+t
ma=m.length

if (k==1) {mw2=ml-w;

for (i=0; i < ma; i++){document.write("<div id='sb"+i+"' class='mn' style='position: absolute; top:"+(mt+mh)+";left:"+(mw+=w+2)+";width:"+(sw[i]-b)+"' onmouseover='o["+i+"].showIt()' onmouseout='o["+i+"].hideIt()'>"+s[i]+"</div>")}

for (i=0; i < ma; i++){document.write("<div style='position: absolute; top:"+mt+";left:"+(mw2+=w+2)+";width:"+w+"' onmouseover='o["+i+"].showIt()' onmouseout='o["+i+"].hideIt()'><a class='bi'"+g+" href='"+n[i]+q+st[i]+a+su[i]+r+m[i]+t+"</div>")}}

else {mw2=mt-mh;mt2=mt-mh+2

for (i=0; i < ma; i++){document.write("<div id='sb"+i+"' class='mn' style='position: absolute; top:"+(mt2+=(mh+1))+";left:"+(ml+w-10)+";width:"+sw[i]+"' onmouseover='o["+i+"].showIt()' onmouseout='o["+i+"].hideIt()'>"+s[i]+"</div>")}

for (i=0; i < ma; i++){document.write("<div style='position: absolute; top:"+(mw2+=(mh+1))+";left:"+ml+";width:"+w+"' onmouseover='o["+i+"].showIt()' onmouseout='o["+i+"].hideIt()'><a class='bi'"+g+" href='"+n[i]+q+st[i]+a+su[i]+r+m[i]+t+"</div>")}}

function lib_obj(obj,nest){nest=(!nest) ? "":'document.'+nest+'.';this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;this.ref=bw.dom||bw.ie4?document:this.css.document;this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0;return this}

function lib_doc_size(){this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;this.x50=this.x2/2;this.y50=this.y2/2;return this;}

lib_obj.prototype.showIt = function(){this.css.visibility="visible"}

lib_obj.prototype.hideIt = function(){this.css.visibility="hidden"}

function libinit(){page=new lib_doc_size();o=new Array();for (i=0; i < ma; i++){o[i]=new lib_obj('sb'+i);o[i].hideIt()}}

libinit()

//-->

</script>
</body>
</html>

a ver quien se atreve a hacerlo funcionar en cualquier navegador... :P

 
Re: Re: Re: Menus desplegables
Enviado por antonio el día 25 de abril de 2004

diurno@iespana.es

es muy bueno el ejemplo me podrias ayudar, para que abra en otro frame que linea tendre que modificar ???

gracias

 


muchas gracias
Enviado por prudenciano magaña garcia el día 2 de diciembre de 2005

Quiero felicitarlos por su excelente codigo de los menús porque realmente funciona y es muy elegante. de antemano muchas gracias y si pudieran enviarme a mi direccion de correo codigo de otro tipo de menus sería magnifico...

agracias!!!!

 



Tienda
Patrocinados
 

Copyright © 1999-2007 Programación en castellano. Todos los derechos reservados.
Formulario de Contacto - Datos legales - Publicidad

Hospedaje web y servidores dedicados linux por Ferca Network

red internet: musica mp3 | logos y melodias | hospedaje web linux | registro de dominios | servidores dedicados
más internet: comprar | recursos gratis | posicionamiento en buscadores | tienda virtual | gifs animados