#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 1999
    Location
    Wichita Falls, TX
    Posts
    9
    Rep Power
    0
    I've got a script that creates a drop down menu with a button click. I want to be able to collapse the menu with a mouse click anywhere on the document. How do I capture that? Help a rookie would ya?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    81
    Rep Power
    15
    The script below pops up an alert box on a right mouse click or on a hold left/click right sequence. You can replace the alert function with whatever you need to collapse your menu. If you really want to collapse the menu with the left button as well (really?), you can add those button strokes.

    RKM


    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    // block the right mouse click on the page
    var message="YOUR MESSAGE"

    function click(e) { //3.0
    if (document.all) {
    if (event.button == 2 &#0124; &#0124; event.button == 3 &#0124; &#0124; event.button == 6 &#0124; &#0124; event.button == 7) {
    alert(message);
    return false;
    }
    }
    if (document.layers) {
    if (e.which == 3) {
    alert(message);
    return false;
    }
    }
    }
    if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;
    // -->
    </SCRIPT>

Similar Threads

  1. more help needed in MFC
    By carol2003 in forum C Programming
    Replies: 8
    Last Post: December 19th, 2003, 02:59 AM
  2. Background change on mouse click
    By dazzz in forum HTML Programming
    Replies: 0
    Last Post: July 9th, 2003, 03:02 PM
  3. javascript for toggling with a mouse click
    By shawn gibson in forum JavaScript Development
    Replies: 4
    Last Post: March 5th, 2002, 07:54 PM
  4. call a function on right mouse click
    By scream in forum HTML Programming
    Replies: 2
    Last Post: March 27th, 2001, 10:15 PM
  5. Disabling right click on mouse button
    By Frostie in forum HTML Programming
    Replies: 4
    Last Post: March 7th, 2001, 04:21 PM

IMN logo majestic logo threadwatch logo seochat tools logo