Web Analytics Made Easy -
StatCounter Disable onMouseOut when onClick event occurred - CodingForum


No announcement yet.

Disable onMouseOut when onClick event occurred

  • Filter
  • Time
  • Show
Clear All
new posts

  • Disable onMouseOut when onClick event occurred

    I have an onMouseOver and onMouseOut event below, I need to find a simple way to add an onClick event to this that disables the onMouseOut event for just one area.
    If they mouse over Map1 then click on it make the Map1 stay as the default until another area is clicked, but keep mouseover function for the rest of the map.

    See all code http://www.wrighter.com/map

    The first two northwest areas are correct now.

    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    imagemap_TheMap = new Image();
    imagemap_TheMap.src = 'TheMap.jpg';
    imagemap_TheMap1 = new Image();
    imagemap_TheMap1.src = 'TheMap1.jpg';
    imagemap_TheMap2 = new Image();
    imagemap_TheMap2.src = 'TheMap2.jpg';
    imagemap_TheMap3 = new Image();
    imagemap_TheMap3.src = 'TheMap3.jpg';;
    imagemap_TheMap4 = new Image();
    imagemap_TheMap4.src = 'TheMap4.jpg';
    imagemap_TheMap5 = new Image();
    imagemap_TheMap5.src = 'TheMap5.jpg';
    imagemap_TheMap6 = new Image();
    imagemap_TheMap6.src = 'TheMap6.jpg';
    imagemap_TheMap7 = new Image();
    imagemap_TheMap7.src = 'TheMap7.jpg';
    imagemap_TheMap8 = new Image();
    imagemap_TheMap8.src = 'TheMap8.jpg';
    imagemap_TheMap9 = new Image();
    imagemap_TheMap9.src = 'TheMap9.jpg';
    imagemap_TheMap10 = new Image();
    imagemap_TheMap10.src = 'TheMap10.jpg';
    imagemap_TheMap11 = new Image();
    imagemap_TheMap11.src = 'TheMap11.jpg';
    function rollOver(iName,iState)
    document.images[iName].src = eval(iName + '_' + iState + '.src');
    // -->

    Here is the html in the area map


    I always have it default to TheMap, so I was looking for an onClick that would change TheMap2 to TheMap until another onClick was made.

    Am I making sense?


  • #2
    Possible. It's common in desktop programming.

    You may need a global variable.

    » Check whether a user does the Click action.
    » Once he's done Click, set the variable to true.
    » If the variable is true, disable your MouseOut event.
    » If the variable is false,your MouseOut event functions as before.
    I mean whenever your Mouseout event performs action, check the variable TRUE or FALSE. If FALSE, Hey Mouseout do the Job! If TRUE, Don't Do That!

    Got it ?


    • #3
      I follow you, but can't wrap my head around were to start.


      • #4
        global variables are any that are defined outside of any explicit scope (like a function or object). You create one just by doing: var globalVariable = "value";

        Then, any thing you define has access to that variable, so you have your function simply run a conditional on globalVariable: if (globalVariable)

        Simple as that.