www.webdeveloper.com
Results 1 to 4 of 4

Thread: drop down menu using javascript

  1. #1
    Join Date
    Nov 2013
    Posts
    44

    drop down menu using javascript

    hi!
    i am trying to creat a drop down menu using js.i have made the menu using onMouseOver event handler.but as soon as i remove the mouse it disappears.what i am trying to say is i cant hold the menu bar on the screen.i only made it for the first list item.
    please help me on this!!
    my codes are---
    Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <style>
    *{margin:0px;padding:0px;}
    #design{
    	width:100%;
    	height:60px;
    	background-color:#00CCFF;
    }
    #design ul {
    	list-style-type:none;
    }
    #design ul li{
    	display:inline-block;
    	margin-left:10px;
    	padding:0px;
    	height:58px;
    	border:0px solid black;
    	
    }
    #design ul li a{
    	text-decoration:none;
    	font-size:30px;
    	border:0px solid black;
    
    	padding:10px;
    	margin-top:0px;
    }
    #clear{
    	background-color:#33FF33;
    	height:110px;
    	width:120px;
    	position:relative;
    	top:-150px;
    }
    #clear ul{
    	list-style-type:none;
    }
    #clear ul li{
    	margin-top:0px;
    	margin-left:5px;
    }
    #clear ul li a {
    	text-decoration:none;
    	font-size:20px;
    }
    #container{
    	width:300px;
    	height:110px;
    	overflow:hidden;
    	border:0px solid;
    }
    </style>
    <script>
    function show(elem){
    
    var drop=document.getElementById(elem);
    drop.style.webkitTransition="top .5s ease-in-out";	
    drop.style.top="0px";
    
    }
    function vanish(elem){
    	var drop=document.getElementById(elem);
    drop.style.webkitTransition="top .5s ease-in-out";	
    drop.style.top="-150px";
    	
    }
    </script>
    </head>
    
    <body>
    <div id="design">
    <ul>
    <li onMouseOver="show('clear');" onMouseOut="vanish('clear');" ><a href="d">home</a></li>
    <li><a href="d">contact us</a></li>
    <li><a href="d">aboutus </a></li>
    <li><a href="g">faqs</a></li>
    </ul>
    </div>
    <div id="container">
    <div  id="clear">
    <ul>
    <li><a href="d">my home</a></li>
    <li><a href="g">yours</a></li>
    <li><a href="r">theirs</a></li>
    <li><a href="e">hers</a></li>
    </ul>
    </div>
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Nov 2013
    Location
    New York City Metro
    Posts
    1
    Here are some JavaScript changes that might help you. I used JavaScript's native setTimeout and clearTimeout functions to set a process which will be delayed by a specified number of milliseconds. When we call vanish, this delayed process (which is held within the global vanishTimeout variable) will be cleared. Within vanish, if reset equals true (reset = true unless otherwise specified), we will create a new delayed process which will hide the menu when executed. This will give the user 500 milliseconds to hover over #clear, preventing it from hiding.

    JavaScript:
    Code:
    var vanishTimeout;
    var milliseconds = 500;
    
    function show(elem){
    	var drop=document.getElementById(elem);
    	drop.style.webkitTransition="top .5s ease-in-out";	
    	drop.style.top="0px";
    }
    
    function vanish(elem, reset){
    	if(typeof reset != 'boolean'){
    		reset = true;
    	}
    	clearTimeout(vanishTimeout);
    	if(reset){
    		vanishTimeout = setTimeout(function(){
    			var drop = document.getElementById(elem);
    			drop.style.webkitTransition="top .5s ease-in-out";	
    			drop.style.top="-150px";
    		}, milliseconds);
    	}
    }
    DOM
    Code:
    <div id="clear" onMouseOver="vanish('clear', false);" onMouseOut="vanish('clear');">

  3. #3
    Join Date
    Nov 2013
    Posts
    44
    thanks!
    i have few questions on your code
    what is the function of this.and what reset not equal to boolean means.and what (reset=true) have to do with your code.can you describe their functions.
    if(typeof reset != 'boolean'){
    reset = true;
    }
    and in here
    onMouseOut="vanish('clear');">
    why you sending without a boolean value???

  4. #4
    Join Date
    Nov 2013
    Location
    Bangladesh
    Posts
    1
    The information is excellent and really helpful.
    http://www. marnetllc.com]IT Network Support[/url]

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.16007 seconds
  • Memory Usage 2,861KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates