Menuaufruf bei Mouseover

fish-guts

Erfahrenes Mitglied
Moin

Hab ein kleines Problem. Möchte in einer Titelleiste was einbauen. Wenn ich mit der Maus über einen Text fahre, soll ein <div> aufgerufen werden.

In IE klappt das auch, aber in FireFox und Netscape nicht. Sieht jemand den Fehler im Code?

Code:
switch (curr){
	case 'c': 
	topCol = "FFFFFF";
	panelCol = "FFFFFF";
	topbarcol1 = "FFFFFF";
	topbarcol2 = "000000";
	break;
}
function lit(td,type) {		    		    	  
	td.style.cursor='hand';
	switch (type) {
		case 'c':
		td.style.backgroundColor='#FF0000';
		td.style.fontSize='14pt';
		break;
	}
}
function unlit(td,type) {	    		    		
	td.style.cursor='hand';
	switch (type) {
		case 'c':
		td.style.backgroundColor='#A50021';
		td.style.fontSize='12pt';
		break;
	}
}
var menuList = new Array('submenu','submenu2');    		    		
function findObj(n,d) {		    			 
	var p,i,x;
	if(!d)
	d = document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; {
		for (i=0;!x&&i<d.forms.length;i++) {
		x=d.forms[i][n];
		}
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
			x=findObj(n,d.layers[i].document);
		}
	return x;
	}
}
function menuShow(menuName) {	    		    	  
	var action
	var boxstate='visible'
	for (var i=0; i< menuList.length; i++) 	{
		if (menuName=='submenu') {
			action='visible'
		}
		else {
			action='hidden'
		}
		var obj=findObj(menuList[i])
		if (obj) {
		if (obj.style) {
			obj=obj.style
			obj.visibility=action
			}
		if (action=='visible') {
			boxstate='visible'
			}
		}
	}
	FormsTweak(boxstate)
}
function menuShow1(menuName) {			/* Wird bei Mouseover aufgerufen! */
	var action
	var boxstate='visible'
	for (var i=0; i< menuList.length; i++) 
	{
		if (menuName==menuList[i])
			action='visible'
		else 
			action='hidden'
		var obj=findObj(menuList[i])
		if (obj) 
		{
			var imageObj = eval("window.metasol_"+menuName);
			 moveLayerTo(obj, imageObj);
			 //getElementRight();
			if (obj.style)
				obj=obj.style
			obj.visibility=action
			if (action=='visible')
			boxstate='visible'
		}
	}
	FormsTweak(boxstate);
}
function FormsTweak(state) {	    		    		
for(var f = 0; f < (document.forms.length); f++) {
	for(var e = 0; e < (document.forms[f].elements.length); e++) {
		if(document.forms[f].elements[e].type=="select-one") {
			document.forms[f].elements[e].style.visibility = state;
			}
		}
	}
}
function isBlank(STR) {
	if (STR == null) STR = '';
	STR += '';
	STR = STR.replace(/^\s+|\s+$/g,'');
	return (STR == '') ? true : false;
}
   
function moveLayerTo(LAYEROBJ, IMAGEOBJ) {
	var LEFT = getX();
	var TOP = getY(IMAGEOBJ);
	LEFT += 4;
	TOP -= 25;
	if (!isBlank(LEFT)) {
			 LAYEROBJ.style.left = LEFT + 'px';
	}
		  if (!isBlank(TOP)) {
			  LAYEROBJ.style.top = TOP + 'px';
	}
}
function getX() {
		return getElementRight();
}

function getY(IMAGEOBJ) {
		return getRealTopPos(IMAGEOBJ);
}

function getRealLeftPos(el) {
	iPos = 0
	while (el!=null) {
		 iPos += el.offsetLeft;
		el = el.offsetParent
	}
	return iPos
}

function getRealTopPos(el) {
	iPos = 0
	while (el!=null) {
		 iPos += el.offsetTop;
		el = el.offsetParent
	}
	return iPos
}

function getElementRight() {
	var nLeftPos = getRealLeftPos(window.metasol);
	var nRightPos = window.metasol.offsetWidth + nLeftPos;
	//alert(nRightPos);
	return nRightPos;
}
function move(fbox, tbox) {	    		    		  
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
	for(i = 0; i < fbox.options.length; i++) {
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if (fbox.options[i].selected && fbox.options[i].value != "") {
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
			}
			else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
			}
		}
		arrFbox.sort();
		arrTbox.sort();
		fbox.length = 0;
		tbox.length = 0;
		var c;
		for(c = 0; c < arrFbox.length; c++) {
		var no = new Option();
			no.value = arrLookup[arrFbox[ C]];
			no.text = arrFbox[ C];
			fbox[ C] = no;
		}
		for(c = 0; c < arrTbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrTbox[ C]];
			no.text = arrTbox[ C];
			tbox[ C] = no;
		}
	document.forms[0].asellist.value = fbox;
	return false;
}

danke und Gruss

FG
 
Moin

Ich geb dir am besten einen Link zur Page:

http://www.burginkasso.ch/index_alt.php

Wenn man in der Titelleiste bei "Leistungen" oder "Newsletter" darüber fährt wird folgendes aufgerufen:

onMouseOver="menuShow1('submenu');lit(this,'c')" onmouseout="menuShow1('');unlit(this,'c')"

Wie gesagt, unter IE geht das, aber unter Netscape und FireFox nicht....

Gruss FG
 
Der Fehler liegt in findObj()

Dort wird abgefragt:
  • document.all
    ...kennt nur IE
  • document.forms
    ....keine drinnen
  • document.layers
    ....kennt nur

... das ist mal wieder ein Skript aus der Mottenkiste.

Wenn das Menu zweidimensional bleiben soll, könntest du hier hereinschauen
 
Zurück