Drop Down Menu - Problem Opening in IE

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Sep 2004
Posts: 49
Reputation: #tbone is an unknown quantity at this point 
Solved Threads: 0
#tbone #tbone is offline Offline
Light Poster

Drop Down Menu - Problem Opening in IE

 
0
  #1
Oct 2nd, 2006
I have used the Suckerfish drop down menu and have run into a problem.

I found the sample code here.

Here is a simplified version of what my code looks like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <style type="text/css">
  2.  
  3. body {
  4. font-family: arial, helvetica, serif;
  5. }
  6.  
  7. #nav, #nav ul { /* all lists */
  8. padding: 0;
  9. margin: 0;
  10. list-style: none;
  11. float : left;
  12. width : 6em;
  13.  
  14. }
  15.  
  16. #nav li { /* all list items */
  17. position : relative;
  18. float : left;
  19. line-height : 1em;
  20. margin-bottom : -1px;
  21. width: 10em;
  22. border: 1px solid #000000;
  23. }
  24.  
  25. #nav li ul { /* second-level lists */
  26. position : absolute;
  27. left: -999em;
  28. margin-left : 9.9em;
  29. margin-top : -1.05em;
  30.  
  31. }
  32.  
  33. #nav li ul ul { /* third-and-above-level lists */
  34. left: -999em;
  35. }
  36.  
  37. #nav li a {
  38.  
  39. display : block;
  40. color : black;
  41. text-decoration : none;
  42. background-color : #FFE8FF;
  43. padding : 0 0.5em;
  44. font-size: 10px;
  45. }
  46.  
  47. #nav li a:hover {
  48. background-color : #FF99FF;
  49. }
  50.  
  51. #nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
  52. left: -999em;
  53. }
  54.  
  55. #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul { /* lists nested under hovered list items */
  56. left: auto;
  57. }
  58.  
  59. #content {
  60. margin-left : 12em;
  61. }
  62.  
  63.  
  64. </style>
  65. <script type="text/javascript"><!--//--><![CDATA[//><!--
  66.  
  67. sfHover = function() {
  68. var sfEls = document.getElementById("nav").getElementsByTagName("LI");
  69. for (var i=0; i<sfEls.length; i++) {
  70. sfEls[i].onmouseover=function() {
  71. this.className+=" sfhover";
  72. }
  73. sfEls[i].onmouseout=function() {
  74. this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  75. }
  76. }
  77. }
  78. if (window.attachEvent) window.attachEvent("onload", sfHover);
  79.  
  80. //--><!]]>
  81. </script>
  82.  
  83. <table align="left">
  84. <tr>
  85. <td>
  86. </tr>
  87. <tr>
  88. <td><ul id="nav">
  89. <li> <a href="javascript:gotoRootURL ()"><strong>Category</strong></a>
  90. <ul>
  91. <li> <a href=""><strong>Petite Tennis Bracelets</strong></a>
  92. <ul>
  93. <li><a href="javascript:gotoRootURL( )"><strong>306</strong></a>
  94. <ul><li><img src="/en/images/productshots/resized/306nav.jpg" alt="306" /></li></ul>
  95. </LI>
  96. <li><a href="javascript:gotoRootURL( )"><strong>1326</strong></a>
  97. <ul><li><img src="/en/images/productshots/resized/1326nav.jpg" alt="1326" /></li></ul>
  98. </LI>
  99. <li><a href="javascript:gotoRootURL( )"><strong>1330</strong></a>
  100. <ul><li><img src="/en/images/productshots/resized/1330nav.jpg" alt="1330" /></li></ul>
  101. </LI>
  102. <li><a href="javascript:gotoRootURL( )"><strong>1331</strong></a>
  103. <ul><li><img src="/en/images/productshots/resized/1331nav.jpg" alt="1331" /></li></ul>
  104. </LI>
  105. </ul>
  106. </li>
  107. <li><a href="javascript:gotoRootURL( 'browser.asp?SKU=185&showcase=yes&Start=0' )"><strong>185</strong></a>
  108. <ul><li><img src="/en/images/productshots/resized/185nav.jpg" alt="185" /></li></ul>
  109. </LI>
  110. </ul>
  111. </li>
  112. </UL>
  113. </td>
  114. </tr>
  115. </table>

Problem 1: is... so far in IE 6 (not able to test in other browsers, but it works in IE 7) when you hover over the "category", the drop down menu pops out to the right, which all works fine.

Then you move your mouse over the "sub 1" menu, which again is fine, until your try to move your mouse down to the "sub 2" menu and then the whole "sub" menu disappears completly.


Problem 2: Can anyone show me how to ensure that the drop down menu will adjust for the size of the page? For instance, when someone scrolls over a part of the menu that is taller or wider than there browser, how can I get the opening menu to stay within the browsers border and not go off-screen?
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Drop Down Menu - Problem Opening in IE

 
0
  #2
Oct 8th, 2006
Without loading this into a Web page, there are a couple of things it could be,

If there is a 1px space between the submenus, the menu will close when you roll over it.

The other common problem is te css for hovering.

As for menu overflow...there is really no foolproof way to do this. I would suggest having the browser check the width of the window vs. the position and width of the menu and reposition the submenus on overflow.

Your best bet is to design your site in such a way that this situation does not happen or happens only under certain conditions that can be easily avoided.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC