1) Script Title: AnyLink Drop-Down Menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...pmenuindex.htm
3) Describe problem:
I am trying to use the menu as unordered list. However, in a long table, menus that are triggered on a link "below the scroll" don't work, and onclick the page jumps back to the top. Another problem is that sometimes I have to click more than once on the link to get the menu. If you copy the table rows in my example below until you get a scrollbar and scroll down to the last row, you will see how the page jumps back up. I don't know how to fix this.
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> body{font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px} .grd_hd_new { background-color: #cacaca; color: #036; font-weight:bold;} .grd_hd2 {background-color: #fff; color:#036; font-weight:bold;} .rowu {background-color: #efefef; color:#000} .rowe {background-color: #e5e5e5; color:#000} .hovermenu {border: 1px solid #e9fecb; border-style:outset; background:#e9fecb; color: #000; padding:2px; margin:2px;} a.hovermenu {color:#000; display:block; width:50px} .slidemenu{position:absolute; border:1px solid black; border-bottom-width: 0; z-index: 100; background-color: #cacaca; width:250px; margin-left:48px; margin-top:-15px; visibility:hidden;} .slidemenu ul {list-style:none; padding: 0; margin: 0 auto;} .slidemenu li{color:#333333; width: 100%; display: block; border-bottom: 1px solid black; padding: 4px; line-height: 1.2em; background-color: #E9FECB; font-weight: normal;} .slidemenu li a:hover{text-decoration: underline;} h2.menu_hd {display:block; background-color:#cacaca; color: #000; font-size: 1em; margin:0; padding:2px; width:101%; font-weight:bold; border-bottom: 1px solid #000} li.menu_more {background-color:#fed;} li.menu_review{background-color:#ffffe1;} </style> <script type="text/javascript"> /*********************************************** * AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds) var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d) var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no) /////No further editting needed var ie5=document.all var ns6=document.getElementById&&!document.all function getposOffset(what, offsettype){ var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent; while (parentEl!=null){ totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; } function showhide(obj, e, visible, hidden){ if (ie5||ns6) dropmenuobj.style.left=dropmenuobj.style.top=-500 if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") obj.visibility=visible else if (e.type=="click") obj.visibility=hidden } function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function clearbrowseredge(obj, whichedge){ var edgeoffset=0 if (whichedge=="rightedge"){ var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15 dropmenuobj.contentmeasure=dropmenuobj.offsetWidth if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth } else{ var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18 dropmenuobj.contentmeasure=dropmenuobj.offsetHeight if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up? edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge } } return edgeoffset } function dropdownmenu(obj, e, dropmenuID){ if (window.event) event.cancelBubble=true else if (e.stopPropagation) e.stopPropagation() if (typeof dropmenuobj!="undefined") //hide previous menu dropmenuobj.style.visibility="hidden" clearhidemenu() if (ie5||ns6){ obj.onmouseout=delayhidemenu dropmenuobj=document.getElementById(dropmenuID) if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'} dropmenuobj.onmouseover=clearhidemenu dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)} showhide(dropmenuobj.style, e, "visible", "hidden") dropmenuobj.x=getposOffset(obj, "left") dropmenuobj.y=getposOffset(obj, "top") dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px" dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px" } return clickreturnvalue() } function clickreturnvalue(){ if ((ie5||ns6) && !enableanchorlink) return false else return true } function contains_ns6(a, b) { while (b.parentNode) if ((b = b.parentNode) == a) return true; return false; } function dynamichide(e){ if (ie5&&!dropmenuobj.contains(e.toElement)) delayhidemenu() else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) delayhidemenu() } function delayhidemenu(){ delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay) } function clearhidemenu(){ if (typeof delayhide!="undefined") clearTimeout(delayhide) } </script> </head> <body> <div id="datatable"> <table cellspacing="0" rules="all" border="1" id="dgMatrix" style="width:100%;border-collapse:collapse;"> <tr class="grd_hd_new" style="font-weight:bold;"> <th scope="col">Actions</th> <th scope="col">Year</th> <th scope="col" width="100%">Name</th> </tr> <tr class="rowe"> <td style="width:5%;"><a href="#" class="hovermenu" onclick="dropdownmenu(this, event, 'menu1')"> Options</a> <div id="menu1" class="slidemenu"> <h2 class='menu_hd'>Tasks</h2> <ul> <li><a href="#">Do this</a></li> <li><a href="#">Do that</a></li> <li class='menu_review'><a href="#">Review this</a></li> <li class='menu_review'><a href="#">Review that</a></li> </ul> </div></td> <td style="width:7%;">2005</td> <td style="width:34%;">Mike</td> </tr> <tr class="rowu" id="AL-EMA1"> <td style="width:5%;"><a href="#" class="hovermenu" onclick="dropdownmenu(this, event, 'menu1')"> Options</a> <div id="menu1" class="slidemenu"> <h2 class='menu_hd'>Tasks</h2> <ul> <li><a href="#">Do this</a></li> <li><a href="#">Do that</a></li> <li class='menu_review'><a href="#">Review this</a></li> <li class='menu_review'><a href="#">Review that</a></li> </ul> </div></td> <td style="width:7%;">2005</td> <td style="width:34%;">John </td> </tr> <tr class="rowe"> <td style="width:5%;"><a href="#" class="hovermenu" onclick="dropdownmenu(this, event, 'menu1')"> Options</a> <div id="menu1" class="slidemenu"> <h2 class='menu_hd'>Tasks</h2> <ul> <li><a href="#">Do this</a></li> <li><a href="#">Do that</a></li> <li class='menu_review'><a href="#">Review this</a></li> <li class='menu_review'><a href="#">Review that</a></li> </ul> </div></td> <td style="width:7%;">2006</td> <td style="width:34%;">Mike</td> </tr> <tr class="rowu" id="AL-EMA1"> <td style="width:5%;"><a href="#" class="hovermenu" onclick="dropdownmenu(this, event, 'menu1')"> Options</a> <div id="menu1" class="slidemenu"> <h2 class='menu_hd'>Tasks</h2> <ul> <li><a href="#">Do this</a></li> <li><a href="#">Do that</a></li> <li class='menu_review'><a href="#">Review this</a></li> <li class='menu_review'><a href="#">Review that</a></li> </ul> </div></td> <td style="width:7%;">2008</td> <td style="width:34%;">John </td> </tr> </table> </div> </body> </html>



Reply With Quote

Bookmarks