Results 1 to 11 of 11

Thread: adding a delay to onmouseover/onmouseout ??

  1. #1
    Join Date
    Dec 2007

    adding a delay to onmouseover/onmouseout ??

    Hi! I'm working on a very simple drop down nav, however I'm trying to figure out a way to make two modifications to it.

    Basically, this is what I want it to do:

    1. When someone hovers over the button, the nav appears. If you keep your mouse hovered where it opens to, then it will stay open. But it can be a little unintuitive for users because it quickly disappears if your mouse trails off it. I'd like to build in a delay so that when you take your mouse off, it doesn't disappear right away. I was trying to insert the window timeout thing but I am so javascript illiterate it's not even funny.

    2. I can live without this, but was having trouble getting the drop down to be relative instead of absolute. I'd like to be able to center the entire design and have the menu stay where it should be on the design. Any ideas? If not, I'll just have to not center it.

    ANYHOO, here's the site and the javascript/css files:



    and, as long as it doesn't affect my rollovers, that would be awesome. The rollovers are made in dreamweaver -- http://kmdgideas.com/ssp/assets/rollovers.js

    Any help is appreciated. I know your time is valuable.

  2. #2
    Join Date
    Jun 2008
    the first would be simple bascally when you call the onmouseout function set a simple timeout like so...

    not sure how how you have it without looking at your site but bascally..

    HTML Code:
    <whateverelement onmouseover="function()" onmouseout="setTimeout(function, 100)" ></whateverelement>
    if you need me to help you more please provide a link to your test page.

    also on the second point im pretty sure any drop down list needs to be positioned absolute if you want it to appear "over" your site, without warping your page.
    Last edited by shakeuk; 06-23-2008 at 04:34 PM.

  3. #3
    Join Date
    Dec 2007
    Hey! Thanks for your help, but I'm not exactly sure how to apply that code when I already have onmouseover and onmouseout's defined for the image rollovers I'm using.

    You can view the page with the links I sent in my previous post. If you hover over sports, the drop down will show up.

    Here's the code I have to work with:

    <a href="sports.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('sports','','images/sports_b.gif',1)"><img src="images/sports_a.gif" alt="Sports" name="sports" width="66" height="28" border="0" id="sports" /></a>
    I tried this but it took the image rollover off, and the timeout didn't work:

    <a href="sports.html" onmouseout="MM_swapImgRestore();setTimeout(function, 100)" onmouseover="MM_swapImage('sports','','images/sports_b.gif',1);function()"><img src="images/sports_a.gif" alt="Sports" name="sports" width="66" height="28" border="0" id="sports" /></a>
    I also switched them around, that didn't seem to work either.

  4. #4
    Join Date
    Jun 2008
    "setTimeout(MM_swapImgRestore(), 100)"
    Did you try this?

  5. #5
    Join Date
    Dec 2007
    SpaceManSpiff: I just put that in onmouseout, no change. MM_swapImageRestore is javascript for the image rollover. I would like for the nav drop down to delay. I'm not even sure if the setTimeout is the right thing to use.

  6. #6
    Join Date
    Jun 2008
    Try bumping the number to 1000 or 2000

  7. #7
    Join Date
    Dec 2007
    Still nothing. I'm not sure how that code is even related to the drop down nav. The MM_swapImgRestore is for the image rollovers. According to the drop_down.js file that I linked to, the function calling the drop down nav was function()... so shouldn't that be in event too? I tried just seperating the two with a semi-colon and that did not seem to work. Is there another way to do that?

    At any rate, I updated the code with the new event and put it online. I have also changed a few things -- now the menu is under PROGRAMS.


  8. #8
    Join Date
    Jun 2008
    Okay ummm, I don't have this infront of me and I've never messed around with functions that are defined on the spot like in the drop_menu.js so if I'm wrong don't flame me please,
    // JavaScript Document
    startList = function() {
    if (document.all && document.getElementById) {
    navRoot = document.getElementById("nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
      node.onmouseover=setTimeout(function() {
      this.className+=" over";
        }, "1000");
      node.onmouseout= setTimeout(function() {
          (" over", "");},"1000");
    Try that, make sure you have semicolons inside the { } and at the end of the setTimeout(); <- like that

    Oh and make sure the brackets match in the function inside setTimeout like this function() {stuff;}

    Seriously make sure the brackets are good cause my eyes are bugging out on this crappy screen and I can't tell if I did them right.
    Last edited by SpaceManSpiff; 06-24-2008 at 12:20 PM.

  9. #9
    Join Date
    Dec 2007
    Flaming isn't my style! I'll let you know how this works out.

  10. #10
    Join Date
    Dec 2007
    The first time I put it in there I thought it worked, but now every time I do it, it doesn't look like anything is happening?

    Ah, don't worry about it. It's not that big of a problem!

  11. #11
    Join Date
    Jun 2008
    ok how about this?:

    // JavaScript Document
    function startList() {
    	function overIt(){
    		this.className+=" over";
    	function offIt(){
    		this.className=this.className.replace(" over", "");
    if (document.all && document.getElementById) {
    navRoot = document.getElementById("nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
    let me know if it works.
    Last edited by shakeuk; 06-24-2008 at 04:05 PM.

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.18243 seconds
  • Memory Usage 2,946KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (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
  • (5)bbcode_code
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)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 (70):
  • 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_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