22 users online (0 members and 22 guests)  


  Results 1 to 2 of 2

Related

  1. Dropdown menu hides behind dropdown box    Forum: Javascript Forum
    Replies: 0
  2. MouseOver Dropdown Menu    Forum: Javascript Forum
    Replies: 3
  3. Dropdown Menu    Forum: CSS Forum
    Replies: 3
  4. Dropdown Menu    Forum: HTML Forum
    Replies: 1
  5. Image Dropdown menu    Forum: Website Scripts Forum
    Replies: 8
  1. #1
    middleburgbmx's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2008
    Location
    Middleburg, FL
    Posts
    13

    Unhappy dropdown menu help

    So, I run a website & am trying to add a dropdown menu to it. I'm using angelfire to host my site. The code works fine whenever I look at a preview on my computer program & on the angelfire preview page. However, once I save it & load the page, the dropdown menu doesn't work. The page has 2 menus, the general navigation menu & the profile menu. The profile menu is what is supposed to be the dropdown menu. I don't know what's going on between the preview & me saving the coding. Can anyone help?? Oh, & on the preview, it works in both IE & FF. Once saved, it doesn't work in either browser. Don't know if that makes a difference or not...
    Thanks in advance!

    http://www.angelfire.com/middleburgbmx/profiles/BH.html

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: dropdown menu help

    The only difference I can imagine is that you are viewing the pages in a preview tool, and that the tool does one of two things. Either it views things differently than a standard browser, or it removed all the semicolons from your javascript. Try adding semicolons to the end of almost every line of javascript and see if that helps.

    Here is the code for you:
    Code:
    //Contents for a-k
    var menu1=new Array();
        menu1[0]='<a href="http://middleburgbmx.angelfire.com/profiles/DA.html">Drew Andersen</a>';
        menu1[1]='<a href="http://middleburgbmx.angelfire.com/profiles/GC.html">Greg Cazares</a>';
        menu1[2]='<a href="http://middleburgbmx.angelfire.com/profiles/JC.html">James Cazares</a>';
        menu1[3]='<a href="http://middleburgbmx.angelfire.com/profiles/MC.html">Mike Clark</a>';
        menu1[4]='<a href="http://middleburgbmx.angelfire.com/profiles/JTD.html">J.T. Davie</a>';
        menu1[5]='<a href="http://middleburgbmx.angelfire.com/profiles/MF.html">Max Field</a>';
        menu1[6]='<a href="http://middleburgbmx.angelfire.com/profiles/CH.html">Clayton Hall</a>';
        menu1[7]='<a href="http://middleburgbmx.angelfire.com/profiles/DH.html">Devin Harrison</a>';
        menu1[8]='<a href="http://middleburgbmx.angelfire.com/profiles/BH.html">Boone Hatcher</a>';
        menu1[9]='<a href="http://middleburgbmx.angelfire.com/profiles/KH.html">Kayleb Higgins</a>';
        menu1[10]='<a href="http://middleburgbmx.angelfire.com/profiles/BK.html">Brandon Kent</a>';
       
    //Contents for l-z
    var menu2=new Array();
        menu2[0]='<a href="http://middleburgbmx.angelfire.com/profiles/RL.html">Russ Lazier</a>';
        menu2[1]='<a href="http://middleburgbmx.angelfire.com/profiles/PL.html">Preston Lewis</a>';
        menu2[2]='<a href="http://middleburgbmx.angelfire.com/profiles/VL.html">Vic Lewis</a>';
        menu2[3]='<a href="http://middleburgbmx.angelfire.com/profiles/BL.html">Blayne Lucas</a>';
        menu2[4]='<a href="http://middleburgbmx.angelfire.com/profiles/BM.html">Billy Maule</a>';
        menu2[5]='<a href="http://middleburgbmx.angelfire.com/profiles/KR.html">Kyla Reed</a>';
        menu2[6]='<a href="http://middleburgbmx.angelfire.com/profiles/MR.html">Marty Rhatigan</a>';
        menu2[7]='<a href="http://middleburgbmx.angelfire.com/profiles/ER.html">Ed Robinson</a>';
        menu2[8]='<a href="http://middleburgbmx.angelfire.com/profiles/ERIV.html">Ed Robinson IV</a>';
        menu2[9]='<a href="http://middleburgbmx.angelfire.com/profiles/RS.html">Ron Sanchez</a>';
        menu2[10]='<a href="http://middleburgbmx.angelfire.com/profiles/BRS.html">Brandon Schlegel</a>';
        menu2[11]='<a href="http://middleburgbmx.angelfire.com/profiles/SS.html">Sage Spess</a>';
        menu2[12]='<a href="http://middleburgbmx.angelfire.com/profiles/SW.html">Samantha Walsh</a>';
    			
    var menuwidth='165px'; //default menu width
    var menubgcolor='#0000cc';  //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="profilemenudiv" 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;
    		parentEl=parentEl.offsetParent;
    	}
    	return totaloffset;
    }
    
    function showhide(obj, e, visible, hidden, menuwidth){
    	if (ie4||ns6)
    		dropmenuobj.style.left=dropmenuobj.style.top="-500px";
    	if (menuwidth!=""){
    		dropmenuobj.widthobj=dropmenuobj.style;
    		dropmenuobj.widthobj.width=menuwidth;
    	}
    	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=ie4 && !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=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset;
    		var windowedge=ie4 && !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 populatemenu(what){
    	if (ie4||ns6)
    		dropmenuobj.innerHTML=what.join("");
    }
    
    function dropdownmenu(obj, e, menucontents, menuwidth){
    	if (window.event) 
    		event.cancelBubble=true;
    	else if (e.stopPropagation) 
    		e.stopPropagation();
    	clearhidemenu();
    	dropmenuobj=document.getElementById? document.getElementById("profilemenudiv") : profilemenudiv;
    	populatemenu(menucontents);
    	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) {
    	while (b.parentNode)
    		if ((b = b.parentNode) == a)
    			return true;
    	return false;
    }
    	
    function dynamichide(e){
    	if (ie4&&!dropmenuobj.contains(e.toElement))
    		delayhidemenu();
    	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    		delayhidemenu();
    }
    
    function hidemenu(e){
    	if (typeof dropmenuobj!="undefined"){
    		if (ie4||ns6)
    			dropmenuobj.style.visibility="hidden";
    	}
    }
    
    function delayhidemenu(){
    	if (ie4||ns6)
    		delayhide=setTimeout("hidemenu()",disappeardelay);
    }
    
    function clearhidemenu(){
    	if (typeof delayhide!="undefined")
    		clearTimeout(delayhide);
    }
    
    if (hidemenu_onclick=="yes") document.onclick=hidemenu;
    Last edited by jthayne; 01-05-2009 at 10:24 AM. Reason: Fixed visual formatting of the code (purely aesthetics)



Tags for this Thread