Roll over menus not working for FF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • govind161986
    New Member
    • Dec 2009
    • 21

    #1

    Roll over menus not working for FF

    I have an old code in a website which shows roll over menu on mouse over event. Now it is not working in FF, Chrome and Safari. only works in IE. Below is the code snippet

    Code:
    // layerTest  class
    <div class=menu id=layerTest style="width: 47; height: 8; layer-background-color: #FFFFFF; border: 1px none #000000; background-color: #FFFFFF"></div>
    
    // Below is the HTML tag for image to show the menu on mouse over function when the functions mentioned in the tag are called on mouseover or mousout event
    
    <td  valign="bottom" width="75" height="15" >
    <a href="#" onMouseOut="timer(0);" onMouseOver="activateMenu(1,'tools',30,19); timer(1);MM_swapImgRestore();MM_swapImage('profile','','images/comp_btn_ov.gif',1)"><img src="images/comp_btn.gif"  border="0"  name="profile" width="75" height="19"></a>
    </td>
    
    // Below is the defination of activateMenu function in javascript include page
    
    function activateMenu(menuLayerRef, imageName, left, top) 
    {
        var lightsout
        
            // I think problem is in a below mentioned line
           var isDynamic = ( ((document.layers && document.layers['layerTest']) || (document.all && document.all['layerTest'])) && !isMacIE );
            
           // layerTest CLASS is define at the starting of this code
    
            if (isDynamic && activeMenu != menuLayerRef) {
    		 if (activeMenu) hideMenu("menu" + activeMenu); 
            menuID = "menu" + menuLayerRef;
            activeMenu = menuLayerRef;
    
            if (isNS) {
                  document[menuID].left = getXCoord(imageName) + left;
                  document[menuID].top = getYCoord(imageName) + top;
            } 
    		else {
    			document.all[menuID].style.pixelLeft = getXCoord(imageName) + left;
    			document.all[menuID].style.pixelTop = getYCoord(imageName) + top;
    		}
    		showMenu(menuID, left, top)
        }
    }
    
    function showMenu(layerID, left, top) {
        eval(layerRef + '["' + layerID + '"]' + 
        styleRef + '.visibility = "visible"');
    }
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Instead of document.layers/document.all, use document.getEle mentById and forget the NS/IE branches. Use document.getEle mentById(menuID ) to reference the element and don't forget the units when setting top/left.

    Comment

    Working...