vForums Support > Programming & Coding :: Code Requests & Support :: > Not working on IE?

Not working on IE? - Posted By ashkir (ashkir) on 7th Aug 11 at 6:26pm
I can get this to work in every browser but Internet Explorer. Anyway to fix it?
Code:
 
  1. <style type="text/css">
  2.  
  3. #popitmenu{
  4. position: absolute;
  5. background-color: white;
  6. border:1px solid black;
  7. font: normal 12px Verdana;
  8. line-height: 18px;
  9. z-index: 100;
  10. visibility: hidden;
  11. }
  12.  
  13. #popitmenu a{
  14. text-decoration: none;
  15. padding-left: 6px;
  16. color: black;
  17. display: block;
  18. }
  19.  
  20. #popitmenu a:hover{ /*hover background color*/
  21. background-color: #CCFF9D;
  22. }
  23.  
  24. </style>
  25.  
  26. <script type="text/javascript">
  27.  
  28. /***********************************************
  29. * Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
  30. * This notice MUST stay intact for legal use
  31. * Visit http://www.dynamicdrive.com/ for full source code
  32. ***********************************************/
  33.  
  34. var defaultMenuWidth="150px" //set default menu width.
  35.  
  36. var linkset=new Array()
  37. //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
  38.  
  39. linkset[0]='<a href="index.cgi">home</a>'
  40. linkset[0]+='<a href="http://starsinsilence.com/action/search">search</a>'
  41. linkset[0]+='<a href="ihttp://starsinsilence.com/action/members">members</a>'
  42. linkset[0]+='<a href="http://starsinsilence.com/action/calendar">calendar</a>'
  43. linkset[0]+='<a href="http://starsinsilence.com/action/view_profile">profile</a>'
  44. linkset[0]+='<a href="http://starsinsilence.com/action/admin">secret</a>'
  45. linkset[0]+='<a href="http://starsinsilence.com/action/login">login</a>'
  46. linkset[0]+='<a href="http://starsinsilence.com/action/logout">logout</a>'
  47.  
  48. linkset[1]='set 2 link 1'
  49. linkset[1]+='set 2 link 2'
  50. linkset[1]+='set 2 link 3'
  51. linkset[1]+='set 2 link 4'
  52.  
  53. ////No need to edit beyond here
  54.  
  55. var ie5=document.all && !window.opera
  56. var ns6=document.getElementById
  57.  
  58. if (ie5||ns6)
  59. document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
  60.  
  61. function iecompattest(){
  62. return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
  63. }
  64.  
  65. function showmenu(e, which, optWidth){
  66. if (!document.all&&!document.getElementById)
  67. return
  68. clearhidemenu()
  69. menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
  70. menuobj.innerHTML=which
  71. menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
  72. menuobj.contentwidth=menuobj.offsetWidth
  73. menuobj.contentheight=menuobj.offsetHeight
  74. eventX=ie5? event.clientX : e.clientX
  75. eventY=ie5? event.clientY : e.clientY
  76. //Find out how close the mouse is to the corner of the window
  77. var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
  78. var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
  79. //if the horizontal distance isn't enough to accomodate the width of the context menu
  80. if (rightedge<menuobj.contentwidth)
  81. //move the horizontal position of the menu to the left by it's width
  82. menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
  83. else
  84. //position the horizontal position of the menu where the mouse was clicked
  85. menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
  86. //same concept with the vertical position
  87. if (bottomedge<menuobj.contentheight)
  88. menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
  89. else
  90. menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
  91. menuobj.style.visibility="visible"
  92. return false
  93. }
  94.  
  95. function contains_ns6(a, b) {
  96. //Determines if 1 element in contained in another- by Brainjar.com
  97. while (b.parentNode)
  98. if ((b = b.parentNode) == a)
  99. return true;
  100. return false;
  101. }
  102.  
  103. function hidemenu(){
  104. if (window.menuobj)
  105. menuobj.style.visibility="hidden"
  106. }
  107.  
  108. function dynamichide(e){
  109. if (ie5&&!menuobj.contains(e.toElement))
  110. hidemenu()
  111. else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
  112. hidemenu()
  113. }
  114.  
  115. function delayhidemenu(){
  116. delayhide=setTimeout("hidemenu()",500)
  117. }
  118.  
  119. function clearhidemenu(){
  120. if (window.delayhide)
  121. clearTimeout(delayhide)
  122. }
  123.  
  124. if (ie5||ns6)
  125. document.onclick=hidemenu
  126.  
  127. </script>