View Full Version : Need Help with Any Link Drop Down Menu

02-22-2007, 02:18 AM
1) Script Title: Any Link Drop Down Menu (mouseover)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

3) Describe problem: I have successfully implemented this script on my page and was able to get all of my naviagtion links working perfectly. Then all of a sudden they stopped working (the links still work the mouseover menu does not). I thought it was b/c of another change I made so I reverted back to when it was working and still didn't work. I created a whole new page starting with only this script and worked one link at a time, it will work a few times, then suddenly stops working. I am using Firefox 1.5 as my browser each time. I can't explain it, it's weird. I'm also using NVU to create my page, might that have something to do with it?

Any thoughts?


02-22-2007, 02:23 AM
Could you post a link to the problem page. It would help us to help you find a solution a lot faster.

02-22-2007, 02:33 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.
Always wanted to use one of those :rolleyes:

02-22-2007, 05:43 AM
Well - I'm only working locally right now so I haven't uploaded it to a site yet. I will paste the html below. Thanks so much for taking a look. I know it's not pretty and it's in tables. I'm a complete amateur but sadly of the 3 of us getting this little non-profit rolling I know the most about web design.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style type="text/css">
border:1px solid black;
border-bottom-width: 0;
font:normal 12px Verdana;
#dropmenudiv a{
width: 100%;
display: block;
text-indent: 3px;
border-bottom: 1px solid black;
padding: 1px 0;
text-decoration: none;
font-weight: bold;
#dropmenudiv a:hover{ /*hover background color*/
background-color: yellow;
<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
//Contents for menu 1 Our Organization
var menu1=new Array()
menu1[0]='<a href="ourorganization.html">Overview</a>'
menu1[1]='<a href="ourorganization.html">Our Core Programs</a>'
menu1[2]='<a href="ourorganization.html">The SNJ Difference</a>'
menu1[3]='<a href="ourorganization.html">Who We Are</a>'
menu1[4]='<a href="ourorganization.html">Our Partners</a>'
//Contents for menu 2 Parents, Schools and Students
var menu2=new Array()
menu2[0]='<a href="pts.html">Parents' Corner</a>'
menu2[1]='<a href="pts.html">Information for Schools</a>'
menu2[2]='<a href="pts.html">Student Forum</a>'
menu2[3]='<a href="pts.html">Forms</a>'
//Contents for menu 3 Donate and Support
menu3[0]='<a href="donate.html">How Can I Help?</a>'
menu3[1]='<a href="donate.html">Donate Online</a>'
var menu3=new Array()
//Contents for menu 4 Contact Us
menu4[0]='<a href="contact.html">General Inquiries</a>'
menu4[1]='<a href="contact.html">Employment Opportunities</a>'
var menu4=new Array()
var menuwidth='200px' //default menu width
var menubgcolor='lightgray' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?
/////No further editting needed
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
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;
return totaloffset;
function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
if (menuwidth!=""){
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
else if (e.type=="click")
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
return edgeoffset
function populatemenu(what){
if (ie4||ns6)
function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
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 (ie4||ns6) return false
else return true
function contains_ns6(a, b) {
if (b){
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
function delayhidemenu(){
if (ie4||ns6)
function clearhidemenu(){
if (typeof delayhide!="undefined")
if (hidemenu_onclick=="yes")
<meta content="text/html; charset=ISO-8859-1"
<title>Sierra Nevada Journeys</title>
<meta content="Home Page" name="description">
style="color: rgb(0, 0, 0); background-color: rgb(202, 202, 202); background-image: url(pleadies.jpg);"
alink="#3366ff" link="#3366ff" vlink="#990099">
<table align="center" border="1" cellpadding="2"
cellspacing="2" width="78%">
<td bgcolor="#333333" height="100%" width="100%">
<table bgcolor="#ffffff" border="1"
cellpadding="0" cellspacing="0" width="100%">
<td width="40%">Logo</td>
<td width="60"><img alt="Banner Picture"
height="116" width="586"></td>
<i><font color="#ffffff">Empowering Youth
Through Positive Risk-Taking, Experiential Leadership, Science and
Outdoor Education</font><br>
<table bgcolor="#000000" border="0"
cellpadding="0" cellspacing="0" height="57"
<td align="center" valign="middle"><b><font
color="#ffffff" face="Helvetica, Arial, sans-serif">Home
&nbsp; &nbsp; &nbsp; &nbsp;
<a href="ourorganization.html"
onclick="return clickreturnvalue()"
onmouseover="dropdownmenu(this, event, menu1, '150px')"
onmouseout="delayhidemenu()">Our Organization</a>
&nbsp; &nbsp; &nbsp; &nbsp;
<a href="tps.html"
onclick="return clickreturnvalue()"
onmouseover="dropdownmenu(this, event, menu2, '150px')"
onmouseout="delayhidemenu()">Parents, Schools &amp; Students</a> &nbsp; &nbsp; &nbsp; &nbsp;
<a href="donate.html" onclick="return clickreturnvalue()"
onmouseover="dropdownmenu(this, event, menu3, '150px')"
onmouseout="delayhidemenu()">Donate &amp; Support</a>
&nbsp; &nbsp; &nbsp; &nbsp;
<a href="contact.html"
onclick="return clickreturnvalue()"
onmouseover="dropdownmenu(this, event, menu4, '150px')"
onmouseout="delayhidemenu()">Contact Us</a><br>
<table border="1" cellpadding="0" cellspacing="0"
height="392" width="983">
<td align="center" bgcolor="#ffffcc"
width="20%">Pictures and Quotes/Navigation</td>
<td align="center" bgcolor="#ffffff"
width="80%"><font face="Helvetica, Arial, sans-serif">Main
About SNJ Home Page</font></td>
<table bgcolor="#000000" border="1"
cellpadding="0" cellspacing="0" height="95"
<td align="center" width="50%"><b><font
color="#ffffff" face="Helvetica, Arial, sans-serif">Research
&amp; Our Favorites</font></b></td>
<td align="center" width="50%"><font
color="#ffffff" face="Helvetica, Arial, sans-serif">News
Releases &amp; Press</font></td>
<table border="0" cellpadding="0" cellspacing="0"
<td bgcolor="#009900"><font color="#ffffff"
face="Helvetica, Arial, sans-serif">Sierra Nevada Journeys
&nbsp;| &nbsp; Phone: &nbsp;775-560-3345 &nbsp;|
&nbsp;Email: &nbsp;jonathan@sierranevadajourneys.org</font></td>

02-28-2007, 07:17 AM
Here is a link to one page that is using this script. I've still been able to get it to work a few times then it just stops working. I know it doesn't make sense, any help would be greatly appreciated.



02-28-2007, 03:40 PM
Ok. I think I found your problem and it lies in the code. Find the following line:

var menu2=new Array()
menu2[0]='<a href="tpsparents.html">Parents' Corner</a>'
menu2[1]='<a href="tpsschools.html">Information for Schools</a>'

and try escaping that quote after "Parents" like so:

var menu2=new Array()
menu2[0]='<a href="tpsparents.html">Parents\' Corner</a>'
menu2[1]='<a href="tpsschools.html">Information for Schools</a>'

That should fix your problem. Hope this helps.

02-28-2007, 07:13 PM
:) Thank you so much! That seems to have fixed it - maybe I'll get this site up after all.