469,330 Members | 1,229 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

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

Expand|Select|Wrap|Line Numbers
  1.  
  2. // layerTest  class
  3. <div class=menu id=layerTest style="width: 47; height: 8; layer-background-color: #FFFFFF; border: 1px none #000000; background-color: #FFFFFF"></div>
  4.  
  5. // 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
  6.  
  7. <td  valign="bottom" width="75" height="15" >
  8. <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>
  9. </td>
  10.  
  11. // Below is the defination of activateMenu function in javascript include page
  12.  
  13. function activateMenu(menuLayerRef, imageName, left, top) 
  14. {
  15.     var lightsout
  16.  
  17.         // I think problem is in a below mentioned line
  18.        var isDynamic = ( ((document.layers && document.layers['layerTest']) || (document.all && document.all['layerTest'])) && !isMacIE );
  19.  
  20.        // layerTest CLASS is define at the starting of this code
  21.  
  22.         if (isDynamic && activeMenu != menuLayerRef) {
  23.          if (activeMenu) hideMenu("menu" + activeMenu); 
  24.         menuID = "menu" + menuLayerRef;
  25.         activeMenu = menuLayerRef;
  26.  
  27.         if (isNS) {
  28.               document[menuID].left = getXCoord(imageName) + left;
  29.               document[menuID].top = getYCoord(imageName) + top;
  30.         } 
  31.         else {
  32.             document.all[menuID].style.pixelLeft = getXCoord(imageName) + left;
  33.             document.all[menuID].style.pixelTop = getYCoord(imageName) + top;
  34.         }
  35.         showMenu(menuID, left, top)
  36.     }
  37. }
  38.  
  39. function showMenu(layerID, left, top) {
  40.     eval(layerRef + '["' + layerID + '"]' + 
  41.     styleRef + '.visibility = "visible"');
  42. }
  43.  
  44.  
Mar 29 '10 #1
1 1385
acoder
16,027 Expert Mod 8TB
Instead of document.layers/document.all, use document.getElementById and forget the NS/IE branches. Use document.getElementById(menuID) to reference the element and don't forget the units when setting top/left.
Apr 29 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Larry R Harrison Jr | last post: by
2 posts views Thread by Peter Sands | last post: by
3 posts views Thread by cefrancke | last post: by
4 posts views Thread by Karl Irvin | last post: by
4 posts views Thread by Bratislav Jevtic | last post: by
6 posts views Thread by dbuchanan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.