www.webdeveloper.com
Results 1 to 2 of 2

Thread: JavaScript Menus

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    JavaScript Menus

    Hello everyone. I need help trying to get my menus to appear when then rolled over regardless of being clicked or not. Here the current code in my menus.js file:

    Code:
    window.onload = init; 
    var activeMenu = null;
    
    function init() {
    	var menus = new Array();
    	var allElms = document.getElementsByTagName("*");
    	
    	for (var i = 0; i < allElms.length; i++) {
    		if (allElms[i].className =="menu") menus.push(allElms[i]);
    	}
    	
    	for (var i = 0; i < menus.length; i++) {
    		menus[i].onclick = changeMenu;
    		menus[i].onmouseover = moveMenu;
    	}
    	
    	document.getElementById("logo").onclick = closeOldMenu ;
    	document.getElementById("linkList").onclick = closeOldMenu ;
    	document.getElementById("page").onclick = closeOldMenu ;
    	document.getElementById("content").onclick = closeOldMenu ;
    }
    function moveMenu() {
    	//This function moves the pull-down menu from one title to another
    	
    	if (activeMenu) {
    		closeOldMenu();
    		
    		menuID= this.id + "List";
    		activeMenu = document.getElementById(menuID);
    		activeMenu.style.display = "block";
    
    
    	}
    }
    
    function changeMenu() {
    	//This function changes the pull-down menu displayed in the document
    	
    	closeOldMenu();
    	
    	menuID = this.id + "List";
    	activeMenu = document.getElementById(menuID);
    	activeMenu.style.display = "block";
    
    	
    }
    function closeOldMenu() {
    	if (activeMenu) {
    		activeMenu.style.display = "none";
    		activeMenu = null;
    	}
    }
    What do I need to change here to get my menus to open if an object is rolled over despite not being clicked?

    Thank you!

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,389

    Question

    How about providing a bit of the HTML so we don't have to start from scratch with a guess as to what you want to see?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles