Forum Moderators: not2easy

Message Too Old, No Replies

Internet Explorer doesn't show submenu

Doctype Issue

         

webprutser

1:11 pm on Feb 11, 2011 (gmt 0)

10+ Year Member



I hope anyone can help me. Thanks to help on this forum I have a good working menu with submenu and subsubmenu. It works fine in Firefox and Google Chrome, but is a complete disaster in that awful Internet Explorer. I wish more website users would be aware of the problem IE causes and would ban that browser. But alas, I have to live with it and find a solution. Apart from positioning problems, my complete submenu and subsubmenu doesn't show up. I hope anyone knows a solution.

This is a relevant part of the HTML code:
<div id= "siteNavigation">
<ul> <!-- begin menu -->
<li><a href="#"><img src="images/button_activiteiten.png" alt="activiteiten"></a> <!-- hoofdmenu button 3 -->
<ul> <!-- submenu button 3 -->
<li><a href="#"><img src="images/button_informatie.png" alt="informatie"></a><!-- submenu button 3.1 -->
<ul> <!-- subsubmenu button 3.1 -->
<li><a href="openingstijd.html"><img src="images/button_opening.png" alt="openingstijd"></a></li> <!-- subsubmenu button 3.1.1 -->
</ul> <!-- einde subsubmenu button 3.1 -->
</li> <!-- einde submenu button 3.1 -->
<li><a href="kinderen.html"><img src="images/button_kinderen.png" alt="kinderen"></a></li> <!-- submenu button 3.2 -->
</ul> <!-- einde submenu button 3 -->
</li> <!-- einde hoofdmenu button 3 -->
</ul><!-- einde menu -->
</div> <!-- //siteNavigation -->

and here is the CSS for the navigation:

#siteNavigation ul {
width:150px; /* of image */
list-style-type:none; /* verwijdert opsommingstekens */
outline:none;
border:none;
margin:0;
padding:0;
}

#siteNavigation ul a img {
border:none;
}

#siteNavigation ul li {
position:relative; /* so the second level takes position from it */
margin:0;
padding:0;
}

#siteNavigation ul li a {
display:block;
height:29px;
}

/* 2nd level */

#siteNavigation ul li:hover ul { /* reveals second level when hovering on the first */
visibility:visible;
}

#siteNavigation ul ul {
visibility:hidden; /* to initially hide the drop down menu */
position:absolute;
top:0px;
left:150px; /*positie submenu t.o.v. hoofdmenu */
width:150px; /* breedte afbeelding */
margin:0;
padding:0;
}

#siteNavigation ul ul a img { /* image dimensions */
display:block;
width:150px;
height:29px;
border:none;
}

#siteNavigation ul ul li {
height:29px; /* height of second level list element matched to image height */
position:relative; /* IH_added for 3rd level */
}

#siteNavigation ul ul li a {
display:block;
height:29px;
}

/* 3rd level */
#siteNavigation ul li:hover ul li ul { /* to initially hide the drop down menu_IH */
visibility:hidden;
position:absolute;
top:0px;
left:150px; /* position subsubmenu */
width:150px; /* width image */
}

#siteNavigation ul ul ul a img { /* image dimensions */
display:block;
width:150px;
height:29px;
border:none;
}

#siteNavigation ul li ul li:hover ul {
visibility:visible; /* reveals 3rd level when hovered */
}

#siteNavigation ul ul ul li {
height:29px; /* height of third level list element matched to image height */
}

How someone knows how to deal with this.

alt131

8:56 pm on Feb 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi webprutser,
I've checked the posted code, and compared it to the code and amendments from the earlier thread [webmasterworld.com]. You've made some adjustments to the positioning, which are being obeyed, and the submenu and sub-submenu are show/hiding fine in ie7 and ie8.

However, you haven't said which version of internet explorer isn't show/hiding the lower level menu's. If ie6 the code won't show/hide because you are activating that by :hover on <li>'s - and ie6 only understands :hover on a link (<a>).

[edited by: tedster at 9:52 pm (utc) on Feb 11, 2011]
[edit reason] Disable graphic smile faces [/edit]

webprutser

9:31 pm on Feb 11, 2011 (gmt 0)

10+ Year Member



I especially downloaded the latest version (IE8) to test my website. In the meantime I am a bit further, with help and more reading/testing. I replaced visibility by display, although that still didn't do the trick. I put the menu code in a separate test-file and at a certain point had things working. The same thing didn't work in the original file however. By removing step by step certain elements I discovered that a little bit of PHP code seemed to be the bottle-neck. To be precisely this is all there is in the file:
<?php
$jaar = date("Y");
?>
at the top of the html file and somewhere at the bottom this code:
<?php echo $jaar; ?>

Removing and adding this code resulted in functioning and not-functioning of the submenu.
I'm pretty new to PHP, but have this piece of code working in an other website, with a simpler type of menu.
Do you happen to understand this behaviour in IE or shall I post it as a PHP question? I can do without the PHP, but would like to understand it or learn what I did wrong.

alt131

10:18 pm on Feb 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wahoo, great problem-solving!

But odd - my php understanding is "very simple", but I can't see anything in the php that should cause a problem, and I dropped it into my version of your html without it affecting the menu as well. On the php side, certainly ask in the php forum as it should be possible to echo out the year without needing to create a variable first - a small detail, for learning, so the php guru's are the best to ask if it's worth changing code that is already working elsewhere.

Back to the menu problem, if the php seems to be "triggering" the problems, but they aren't showing up in the code you've posted here, then this is a "false positive" (only seems to be the cause of the problem, and isn't really), or there is something else in your code (not in the code posted to the thread ) that is reacting with the php and causing the troubles. I know stripping code is tedious, but can you do the following:
1. Go back through your code, stripping out all the style-only things until you have the smallest page that shows the problem.
2. Validate [validator.w3.org] the html and css to double-check that's not an issue
3. Post the whole of your page (from DOCTYPE to </html>) to the thread.

webprutser

12:32 am on Feb 12, 2011 (gmt 0)

10+ Year Member



All right, that makes sense to me. At first I will check something else, I noticed some differences in the header between your file and mine, but after the "success" of the PHP removal I didn't look at it any more. I will do as you suggested (I did validate my html and css file already, but will do again after the "stripping out").
As I live in Europe it's about bed time. Especially after a short night like yesterday, dealing with submenu-problems. :-)
Thanks for your input and I will be back with the results.

webprutser

9:20 pm on Feb 12, 2011 (gmt 0)

10+ Year Member



As said before I noticed some differences in the header between your file and mine. I started by replacing my header by your header to see what happened. The website looked fine in both firefox and internet explorer. So I commented out several elements to see what happened and the key problem was the DOCTYPE. I had read about it, especially with regard to Internet Explorer, even validated my test file as strict, but somehow I must have done something wrong, for as soon as I used your doctype declaration all rendering problems were gone. The PHP code is back in place and causes no problem.
You can imagine I'm rather happy at the moment. I did some more reading on doctype, there is a very useful page in wikipedia about it ("quirks mode") and it is clear, why my site was acting odd with the wrong doc type.
Thanks for your help.

alt131

3:09 am on Feb 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think I sent you a "header", so can't take credit for that, but am delighted this is resolved. Also that you resolved it yourself - feels good doesn't it ;) - and hope you're really pleased with your problem solving.

I wondered about doctype and intended to check when you posted the full code - now you've read about them you understand why. Thanks for the reference to the page at Wikipedia - an interesting read. You might also be interested in three WebmasterWorld threads that are often referred to:
Choosing the best docype for your site [webmasterworld.com]
What's your doctype [webmasterworld.com]
Why most of us should not use xhtml [webmasterworld.com]

webprutser

2:11 pm on Feb 13, 2011 (gmt 0)

10+ Year Member



I mixed things up.
Found a posting on a similar problem as I was dealing with, on an other forum and got some code over there, but this forum stands out in quality of response. It looks like this is going to be my main source for help in future cases.

The pages you linked to are very interested, I bookmarked them. When you make a new HTML file with PSPad it comes up with the Transitional Doc Type, without URL, so the type you'd better not use (as I found out). I tried to find a setting option to change it, but couldn't find it.
Generally spoken I am rather content with (and used to) PSPad, so I just have to pay attention to it when making something new (or start a new file by using a copy of an existing one).
Anyway, I learnt a lot about the importance and differences between DOC types AND my problem is solved. What more can one wish for?