SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: onContextMenu

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    BOSTON
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onContextMenu

    yeah.... right
    oncontextmenu
    i am making an app that has a different contextmenu for a hierarchical tree of links,
    so that each element of the tree has a different menu

    and each part of the tree is made so that the name or picture (looks just like the windows explorer tree)
    the link is genereated dynamicly, and within that generation, the <a href="www.whatever" oncontextmenu="differentMENU">CHECK THIS LINK</a>
    SO THAT A LINK HAS ONE MENU,
    A FOLDER HAS ANOTHER MENU
    AND THE ROOT FOLDER IS COMPLETELY DISABLED

    has anyone experience overloading the oncontextmenu event handler for anchors???
    and should this be in beginners???
    OH F
    anyways, any feed back is greatly appreciated
    thanks!!
    PEACE

  2. #2
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really for total neophytes, but it wouldn't be that hard.

    Make sure that you do onContextMenu="return false" to disable the browser's own menu from showing up on right-click. You normally put this attribute in your <BODY> tag.

    You might want to post this in the JS forum... You'd probably get more help.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    BOSTON
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reply time

    being the ILL SKILLED developing fool that i am
    i got the bad larry to work!!
    check it out:
    basicly i just made a couple contextmenu functions that are inserted into the link, or folder at creation time
    (remember tree is made dynamicly)
    <code>
    <script language="JavaScript1.2">
    document.oncontextmenu = disable;
    if (document.all && window.print){
    document.body.onclick = hidemenu;
    }
    </script>
    <!-- hidemenu clears both contextmenus -->
    </code>
    and here is an example of the two links that are generated

    <a href="http://www.sitepointforums.com" id="link" oncontextmenu="showItemMenu()">PHP!</a>
    <br>
    <hr>
    <a href="http://www.google.com" id="nolink" oncontextmenu="showFolderMenu()">Google</a>
    i went at the problem trying to make it so that the over event had some way of determing what type the link was (some OO programming in the back-end of the javascript tree)
    thanks a bunch
    PEACE


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •