| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Aug 2004 Location: Sweden
Posts: 2
![]() | DHTML navigation menu I'm trying to make a simple text-based menu that expands similarly to how folders expand in windows explorer. I've tried 2 different ways to achieve this, and both works flawlessly in IE and Opera. However, in Firefox (and Mozilla too I would guess since they were both made by Mozilla), the submenus refuses to expand. I'm out of clues now and I'm desperate for some help. I need the script to work on as many different browsers as I can. The script is as follows: <!-- Hide script from older browsers // Open the menu specified by 'currMenu' function toggleMenu(currMenu) { var thisMenu; var thisPic = eval("document.menu" + currMenu + "p"); var menuOffsets = new Array(88, 124, 52, 52); // => 12 * Rader + 4 <=> Rader * 10 + (Rader + 2) * 2 var openMenus = new Array(0, 0, 0, 0); var menu2o; var menu3o; var menu4o; var menu5o; if(document.all) { thisMenu = eval("document.all.menu" + currMenu + "content.style"); menu2o = eval("document.all.menu2.style"); menu3o = eval("document.all.menu3.style"); menu4o = eval("document.all.menu4.style"); menu5o = eval("document.all.menu5.style"); } else if(document.getElementById) { thisMenu = eval("document.getElementById('menu" + currMenu + "content')"); menu2o = eval("document.getElementById('menu2')"); menu3o = eval("document.getElementById('menu3')"); menu4o = eval("document.getElementById('menu4')"); menu5o = eval("document.getElementById('menu5')"); } else { thisMenu = eval("document.menu" + currMenu + "content"); menu2o = eval("document.menu2"); menu3o = eval("document.menu3"); menu4o = eval("document.menu4"); menu5o = eval("document.menu5"); } if(thisMenu.display == "block") { thisMenu.display = "none"; thisPic.src = "images/plus.gif"; openMenus[currMenu-1] = 0; } else { thisMenu.display = "block"; thisPic.src = "images/minus.gif"; ????: NamePros.com http://www.namepros.com/programming/43724-dhtml-navigation-menu.html openMenus[currMenu-1] = 1; } menu2o.top = 32 + menuOffsets[0]*openMenus[0]; menu3o.top = 44 + menuOffsets[0]*openMenus[0] + menuOffsets[1]*openMenus[1]; menu4o.top = 56 + menuOffsets[0]*openMenus[0] + menuOffsets[1]*openMenus[1] + menuOffsets[2]*openMenus[2]; menu5o.top = 68 + menuOffsets[0]*openMenus[0] + menuOffsets[1]*openMenus[1] + menuOffsets[2]*openMenus[2] + menuOffsets[3]*openMenus[3]; } // Stop hiding script --> In Firefox the images will change correctly, but the submenus will not appear (the .display = "block" part) and the last bit where the top properties of the menus are changed doesn't work either. The Firefox JavaScript Console finds no errors in the script
__________________ "How do we prove that we exist? Maybe we don't exist..." - Vivi, FFIX |
| |