Small menu popup on hover via CSS - IE prob

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

Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Small menu popup on hover via CSS - IE prob

 
0
  #1
Apr 2nd, 2008
Hey all,

I'm trying to make a small menu popup via CSS. On rollover, the link should display another set of links below the link that the mouse is hovering on. The code Below works in FF but not in IE. Could someone help out? Thanks.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. style.css
  2.  
  3. .navigation {
  4. margin: 0.5em;
  5. padding: 0.3em;
  6. border: 1px solid #C4C4C4;
  7. text-align: left;
  8. }
  9. .navigation li a:link, a:visited{
  10. color: #545454;
  11. text-decoration: none
  12.  
  13. }
  14. .navigation li a:hover{
  15. color: #72C32B;
  16. }
  17. .navigation li a:active {
  18. color: #545454;
  19. text-decoration: none
  20. }
  21. .navigation ul{
  22. list-style-type: none;
  23. margin: 0.3em 0 0.1em 0.1em;
  24. padding: 0em 0 0.1em 1em;
  25. }
  26.  
  27. .navigation li .popup {
  28. display:none;
  29. background-color:white;
  30. background-style:solid;
  31. position:float;
  32. }
  33. .navigation li:hover .popup,
  34. .navigation li:focus .popup,
  35. .navigation li:active .popup {
  36. display:block;
  37. }


JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. nav.html
  2.  
  3. <div class="navigation">
  4. <ul>
  5. <li><a href="Home.html">Home</a></li>
  6. <li>
  7. <a href="#">Links</a>
  8. <div class="popup">
  9. <ul>
  10. <li><a href="link1.html">Link 1</a></li>
  11. <li><a href="link2html">Link 2</a></li>
  12. <li><a href="link3.html">Link 3</a></li>
  13. </ul>
  14. </div>
  15. </li>
  16. </ul>
  17. </div>
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 58
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Re: Small menu popup on hover via CSS - IE prob

 
0
  #2
Apr 3rd, 2008
hi
use javaScript as follows:
<a href="#" onmouseover="javascript:fun1();" onmouseout="javascript:fun2()">Links</a>
where inside fun1() put
document.getElementById("div_p").style.display="block";
and inside fun2() put
document.getElementById("div_p").style.display="none";
where div_p is id of "popup" tag
.....i hope it solves your problem.
if you find to do something like this in IE also plz put here...
have a nice time !!!
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: Small menu popup on hover via CSS - IE prob

 
0
  #3
Apr 3rd, 2008
Originally Posted by DangerDev View Post
hi
use javaScript as follows:
<a href="#" onmouseover="javascript:fun1();" onmouseout="javascript:fun2()">Links</a>
where inside fun1() put
document.getElementById("div_p").style.display="block";
and inside fun2() put
document.getElementById("div_p").style.display="none";
where div_p is id of "popup" tag
.....i hope it solves your problem.
if you find to do something like this in IE also plz put here...
have a nice time !!!

Hey,

Thanks for the help however I get an error when I attempt to run this code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. javascript
  2.  
  3. <script language="javascript">
  4. function displayMenu() {
  5. document.getElementById("popup").style.display = "block";
  6. }
  7.  
  8. function hideMenu() {
  9. document.getElementById("popup").style.display = "none";
  10. }
  11. </script>
  12.  
  13. html
  14.  
  15. <div class="navigation">
  16. <h2>Menu</h2>
  17. <ul>
  18. <li>
  19. <a href="#" onMouseOver="javascript:displayMenu();" onMouseOut="javascript:hideMenu();">Links</a>
  20. <div class="popup">
  21. <ul>
  22. <li><a href="Link1.html">Link1</a></li>
  23. <li><a href="Link2.html">Link2</a></li>
  24. <li><a href="Link3.html">Link3</a></li>
  25. </ul>
  26. </div>
  27. </ul>
  28. </div>

I get an "Object required" error within both of the function where document.getelementbyid... is.

Any suggestions?
Last edited by Barefootsanders; Apr 3rd, 2008 at 12:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: Small menu popup on hover via CSS - IE prob

 
0
  #4
Apr 3rd, 2008
btw, popup is a nested div. Would that make any difference?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: Small menu popup on hover via CSS - IE prob

 
0
  #5
Apr 3rd, 2008
Ok i figured out what I was doing wrong. My popup div did not have an ID. But now I have another problem... The popup works when the mouse is over the parent link but when you go to choose one of the sub links, the onMouseOut is fired and the links disappear. Is there a way around this? Thanks.
Reply With Quote Quick reply to this message  
Reply

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



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