Ver Mensaje Individual
  #8 (permalink)  
Antiguo 03/01/2005, 13:03
m160858
 
Fecha de Ingreso: octubre-2004
Mensajes: 7
Antigüedad: 19 años, 6 meses
Puntos: 0
Yo tengo un problema con mi menu javascript, tengo el menu sobre una intro flash y en IE me funciona sin problemas ... sin embargo en firefox el menu me aparece por debajo del flash.... pueden darme una mano por favor.

function Menu ( id, cssClass, cssOverClass) {
this.overCSS = cssOverClass;

this.id = Menu.register( this );

this.cell = document.getElementById( id );
this.cell.menuInst = this;
this.cell.onmouseover = Menu.forwardCellEvent;
this.cell.onmouseout = Menu.forwardCellEvent;

this.menu = document.createElement( "SPAN" );
document.body.appendChild( this.menu );
this.menu.style.position = "absolute";
this.menu.style.display = "none";
this.menu.style.zIndex = 20;

var table = document.createElement( "TABLE" );
this.menu.appendChild( table );
table.cellSpacing = 0;
table.cellPadding = 0;
table.className = cssClass;

this.tableBody = document.createElement( "TBODY" );
table.appendChild( this.tableBody );
}

Menu.prototype.hideTimeout = null;
Menu.prototype.shown = false;

Menu.prototype.addItem = function ( text, url ) {
var tr = document.createElement( "TR" );
this.tableBody.appendChild( tr );
var cell = document.createElement( "TD" );
tr.appendChild( cell );

cell.menuInst = this;
cell.url = url;
cell.innerHTML = "<img src='images/arrow.gif' width=14 height=9>" + text;
cell.style.borderBottom = "1px solid #999999";
cell.style.padding = "4 4 4 4";
cell.style.zIndex = 20;
cell.style.cursor = ns ? "pointer" : "hand";
cell.onmouseover = Menu.forwardItemEvent;
cell.onmouseout = Menu.forwardItemEvent;
cell.onclick = Menu.forwardItemEvent;
}

Menu.prototype.showMenu = function () {
var image = this.getImage();
image.src = this.getImageURL( "on" );

var topOffset = leftOffset = 0;
var curParent = this.cell;
while ( curParent ) {
topOffset += curParent.offsetTop;
leftOffset += curParent.offsetLeft;
curParent = curParent.offsetParent;
}

this.menu.style.top = topOffset + this.cell.offsetHeight;
this.menu.style.left = leftOffset;
this.menu.style.display = "block";

if ( !this.shown ) {
Menu.closeAll();
this.shown = true;
}
}

Menu.prototype.getImage = function () {
if ( this.cell.children ) return this.cell.children[ 0 ].children[ 0 ];
var child = this.cell.childNodes[ 1 ];
if ( child.childNodes[0].tagName == "IMG" ) return child.childNodes[ 0 ];
return child.childNodes[ 1 ];
}

Menu.prototype.getImageURL = function ( status ) {
var url = this.getImage().src;
return url.substr( 0, url.indexOf(this.cell.id) ) + this.cell.id + "-" + status + ".gif";
}

Menu.prototype.hideMenu = function () {
this.getImage().src = this.getImageURL( "off" );
this.menu.style.display = "none";
this.shown = false;
}

Menu.prototype.mouseoverCellHandler = function () {
this.cancelHide();
this.showMenu();
}

Menu.prototype.startHide = function () {
this.cancelHide();
this.hideTimeout = setTimeout( "Menu.insts[" + this.id + "].hideMenu()", 400 );
}

Menu.prototype.mouseoutCellHandler = Menu.prototype.startHide;

Menu.prototype.cancelHide = function () {
if ( this.hideTimeout ) clearTimeout( this.hideTimeout );
}

Menu.prototype.clickItemHandler = function ( cell ) {
document.location.href = cell.url;
}

Menu.prototype.mouseoverItemHandler = function ( cell ) {
this.cancelHide();
cell.className = this.overCSS;
}

Menu.prototype.mouseoutItemHandler = function ( cell ) {
cell.className = "";
this.startHide();
}

Menu.forwardCellEvent = function ( event ) {
Menu.forwardEvent( event, "Cell" );
}

Menu.forwardItemEvent = function ( event ) {
Menu.forwardEvent( event, "Item" );
}

Menu.forwardEvent = function ( event, type ) {
if ( !event ) event = window.event;
var curElement = event.srcElement || event.target;
while ( curElement && curElement.tagName != "TD" )
curElement = curElement.parentElement || curElement.parentNode;
if ( !curElement ) return;
curElement.menuInst[ event.type + type + "Handler" ]( curElement );
}

Menu.insts = [];

Menu.register = function ( inst ) {
var id = Menu.insts.length;
Menu.insts[ id ] = inst;
return id;
}

Menu.closeAll = function () {
for ( var i=0; i < Menu.insts.length; i++ ) {
var inst = Menu.insts[ i ];
if ( inst.shown ) inst.hideMenu();
}
}

Menu.unavailable = document.layers || ( navigator.platform == "MacPPC" && this.name == "Microsoft Internet Explorer" );

var ns = ( navigator.appName == "Netscape");
if ( ns ) {
HTMLElement.prototype.__defineGetter__(
"children",
function () {
var tmp = [];
var j = 0;
var n;
for ( var i = 0; i < this.childNodes.length; i++ ) {
n = this.childNodes[ i ];
if ( n.nodeType == 1 ) {
tmp[ j++ ] = n;
if ( n.name ) {
if ( !tmp[n.name] )
tmp[n.name] = [];
tmp[ n.name ][ tmp[n.name].length ] = n;
}
if ( n.id ) tmp[ n.id ] = n;
}
}
return tmp;
}
);
}