+ Reply to Thread
Results 1 to 4 of 4

Thread: Drop-Down Menu problems

  1. #1
    gmshed is offline x10Hosting Member gmshed is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    10

    Unhappy Drop-Down Menu problems

    I'm making a smooth drop-down menu for a site. You hover over the button, the menu drops down, you leave the menu, it scrolls back up.

    To see it, go to www.gmshed.com/skyfire and hover over "World in War".

    Problems:
    If you hover over the button, and then leave the button when the menu's scrolled down, not moving over the menu, it stays up.
    If you move the cursor around the menu while it's open, it closes
    If you hover over a button in the menu, it closes

    Script:
    Code:
    image1 = new Image();
    image1.src = 'images/nav_button_hover.png';
    image2 = new Image();
    image2.src = 'images/game_button_hover.png';
    image3 = new Image();
    image3.src = 'images/menu_button_hover.png';
    open['wiwmenu'] = 0;
    stayopen = false;
    function hoverButton(button)
    {
      document.getElementById(button).className = 'navbuttonhover';
    }
    function restoreButton(button)
    {
      document.getElementById(button).className = 'navbutton';
    }
    function pressButton(button)
    {
      document.getElementById(button).className = 'navbutton';
    }
    function releaseButton(button,page)
    {
      document.getElementById(button).className = 'navbuttonhover';
      document.location = page;
    }
    function gHoverButton(button)
    {
      document.getElementById(button).className = 'gamebuttonhover';
    }
    function gRestoreButton(button)
    {
      document.getElementById(button).className = 'gamebutton';
    }
    function gPressButton(button)
    {
      document.getElementById(button).className = 'gamebutton';
    }
    function gReleaseButton(button,game)
    {
      document.getElementById(button).className = 'gamebuttonhover';
    }
    function mHoverButton(button)
    {
      document.getElementById(button).className = 'menubuttonhover';
    }
    function mRestoreButton(button)
    {
      document.getElementById(button).className = 'menubutton';
    }
    function mPressButton(button)
    {
      document.getElementById(button).className = 'menubutton';
    }
    function mReleaseButton(button,page)
    {
      document.getElementById(button).className = 'menubuttonhover';
      document.location = page;
    }
    function openMenu(menu,mheight,speed)
    {
      currentheight = document.getElementById(menu).style.height.replace('px','')*1;
      intervalo = setInterval('rollOutMenu("'+menu+'",'+mheight+','+speed+');',1);
      open[menu] = 2;
    }
    function closeMenu(menu,speed)
    {
      currentheight = document.getElementById(menu).style.height.replace('px','')*1;
      interval = setInterval('rollInMenu("'+menu+'",'+speed+');',1);
      open[menu] = 3;
    }
    function rollOutMenu(menu,mheight,speed)
    {
      if (currentheight<mheight)
      {
          currentheight += speed;
          document.getElementById(menu).style.height = currentheight+'px';
          document.getElementById(menu+'box').style.height = 30+currentheight+'px';
          //document.getElementById(menu+'click').style.height = 30+currentheight+'px';
      }
      else
      {
          document.getElementById(menu).style.height = mheight+'px';
          document.getElementById(menu+'box').style.height = mheight+30+'px';
          //document.getElementById(menu+'click').style.height = mheight+30+'px;';
          clearInterval(intervalo);
          open[menu] = 1;
      }
    }
    function rollInMenu(menu,speed)
    {
      if (currentheight>1)
      {
          currentheight -= speed;
          document.getElementById(menu).style.height = currentheight+'px';
          document.getElementById(menu+'box').style.height = 30+currentheight+'px';
          //document.getElementById(menu+'click').style.height = 30+currentheight+'px';
      }
      else
      {
          document.getElementById(menu).style.height = '1px';
          document.getElementById(menu+'box').style.height = '32px';
          //document.getElementById(menu+'click').style.height = '32px;';
          clearInterval(interval);
          open[menu] = 0;
      }
    }
    CSS:
    Code:
    .gamebutton { width: 100px; height: 32px; background-image: url('game_button.png'); margin-right: 20px; cursor: pointer; position: absolute; }
    .gamebuttonhover { width: 100px; height: 32px; background-image: url('game_button_hover.png'); margin-right: 20px; cursor: pointer; position: absolute; }
    .menu { width: 100px; height: 32px; padding: 0px; margin-top: 12px; }
    .menunw { width: 15px; height: 15px; background-image: url('menu_nw.png'); }
    .menune { width: 15px; height: 15px; background-image: url('menu_ne.png'); }
    .menusw { width: 15px; height: 15px; background-image: url('menu_sw.png'); }
    .menuse { width: 15px; height: 15px; background-image: url('menu_se.png'); }
    .menun { height: 15px; background-image: url('menu_n.png'); }
    .menus { height: 15px; background-image: url('menu_s.png'); }
    .menue { width: 15px; background-image: url('menu_e.png'); }
    .menuw { width: 15px; background-image: url('menu_w.png'); }
    .menumid { background-color: #000000; }
    .menutable { position: absolute; width: 100px; height: 32px; overflow: hidden; }
    .menubutton { width: 64px; height: 24px; background-image: url('menu_button.png'); margin-top: 8px; cursor: pointer; }
    .menubuttonhover { width: 64px; height: 24px; background-image: url('menu_button_hover.png'); margin-top: 8px; cursor: pointer; }
    Code on page:
    Code:
    <center><div class="menu" id="wiwmenubox" onmouseover="setTimeout('if (open[\'wiwmenu\']==0) { openMenu(\'wiwmenu\',100,5); }',1);" onmouseout="setTimeout('if (open[\'wiwmenu\']==1 && !stayopen) { closeMenu(\'wiwmenu\',5); }',2);">
    <table class="menutable" cellspacing="0" cellpadding="0" onmouseover="setTimeout('stayopen = false;',2);">
    <tr><td class="menunw"></td><td class="menun"></td><td class="menune"></td></tr>
    <tr><td class="menuw"></td><td class="menumid"><div id="wiwmenu" style="height: 1px; overflow: hidden; ">
    <br />
    <table cellspacing="0" class="menubutton" id="wiwinfobutton" onmouseover="stayopen = true; mHoverButton('wiwinfobutton');" onmouseout="mRestoreButton('wiwinfobutton');" onmousedown="mPressButton('wiwinfobutton');" onmouseup="mReleaseButton('wiwinfobutton','wiwinfo');"><tr><td><center><b><span style="margin: 8px;">Info</span></b></center></td></tr></table>
    </div></td><td class="menue"></td></tr>
    <tr><td class="menusw"></td><td class="menus"></td><td class="menuse"></td></tr>
    </table>
    <table class="gamebutton" id="wiwbutton" cellspacing="0" onmouseover="gHoverButton('wiwbutton');" onmouseout="stayopen = true; gRestoreButton('wiwbutton');" onmousedown="gPressButton('wiwbutton');" onmouseup="gReleaseButton('wiwbutton','1');"><tr><td><center><b>World in War</b></center></td></tr></table>
    </div></center>

    If anyone could help, I'd really appreciate it. make sure you go to www.gmshed.com/skyfire so you can understand what I mean. Plus all the javascript's at www.gmshed.com/skyfire/scripts/skyfire.js, and the css is at www.gmshed.com/skyfire/images/style.css. I just put it here to make it more convenient.

  2. #2
    websoul is offline x10Hosting Member websoul is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    39

    Re: Drop-Down Menu problems

    why u r doing on mouseout
    close that or hide div or apply the style when some other menu is clicked.U can do it by java scripts.identify the active menu and set its style as u want...

    Hope this help
    Websoul - a good web's Soul ;)

  3. #3
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Drop-Down Menu problems

    Well he said he wants the effect to take place when the user's mouse leaves that area, not when they click another menu. However I do agree this could be coded a bit better.

    But anyway, I think if you change

    Code:
    <table class="menutable" cellspacing="0" cellpadding="0" onmouseover="setTimeout('stayopen = false;',2);">
    to..

    Code:
    <table class="menutable" cellspacing="0" cellpadding="0" onmouseout="stayopen=false" onmouseover="stayopen=true">
    and

    Code:
    <table class="gamebutton" id="wiwbutton" cellspacing="0" onmouseover="gHoverButton('wiwbutton');" onmouseout="stayopen = true; gRestoreButton('wiwbutton');" onmousedown="gPressButton('wiwbutton');" onmouseup="gReleaseButton('wiwbutton','1');">
    to...

    Code:
    <table class="gamebutton" id="wiwbutton" cellspacing="0" onmouseover="stayopen=true; gHoverButton('wiwbutton');" onmouseout="stayopen = false; gRestoreButton('wiwbutton');" onmousedown="gPressButton('wiwbutton');" onmouseup="gReleaseButton('wiwbutton','1');">
    then it'll work the way you want it to.
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  4. #4
    gmshed is offline x10Hosting Member gmshed is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    10

    Re: Drop-Down Menu problems

    Quote Originally Posted by woiwky View Post
    Well he said he wants the effect to take place when the user's mouse leaves that area, not when they click another menu. However I do agree this could be coded a bit better.

    But anyway, I think if you change

    Code:
    <table class="menutable" cellspacing="0" cellpadding="0" onmouseover="setTimeout('stayopen = false;',2);">
    to..

    Code:
    <table class="menutable" cellspacing="0" cellpadding="0" onmouseout="stayopen=false" onmouseover="stayopen=true">
    and

    Code:
    <table class="gamebutton" id="wiwbutton" cellspacing="0" onmouseover="gHoverButton('wiwbutton');" onmouseout="stayopen = true; gRestoreButton('wiwbutton');" onmousedown="gPressButton('wiwbutton');" onmouseup="gReleaseButton('wiwbutton','1');">
    to...

    Code:
    <table class="gamebutton" id="wiwbutton" cellspacing="0" onmouseover="stayopen=true; gHoverButton('wiwbutton');" onmouseout="stayopen = false; gRestoreButton('wiwbutton');" onmousedown="gPressButton('wiwbutton');" onmouseup="gReleaseButton('wiwbutton','1');">
    then it'll work the way you want it to.
    Thanks, it's working now.
    With all the timeouts and stayovers I was getting confused with my own code.

+ Reply to Thread

Similar Threads

  1. 300 short cuts of Windows XP
    By goodone in forum Computers & Technology
    Replies: 34
    Last Post: 11-29-2011, 12:12 AM
  2. Mobile phone Codes
    By greeting in forum Computers & Technology
    Replies: 10
    Last Post: 03-28-2008, 07:08 AM
  3. NOTE: For all problems regarding phpBB3 RC6
    By CrownVictoriaCop in forum Free Hosting
    Replies: 1
    Last Post: 10-14-2007, 03:35 PM
  4. Joomla - Problem with URL links in Menu
    By Axe_Swipe in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 08-29-2007, 08:44 PM
  5. problems, problems
    By joandajer in forum Free Hosting
    Replies: 5
    Last Post: 01-29-2006, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers