SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    right click link menu

    Does anyone know of a script that will display a special context menu when certain links are right clicked? I am trying to make an online script, and I want to give it a windows explorer type feel.

    Thanks.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    On Windows computers the context menu is defined in the registry of the computer. Most browsers don't even allow web pages any interaction with the context menu at all. There are options available within Internet Explorer that can do it provided that the computer is configured correctly so that custom context menus are possible on an intranet.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a script that is cross browser compatible, but it displays the menu when any part of the page is clicked. I just need it to display when certain links are right clicked. http://www.dynamicdrive.com/dynamici...ontextmenu.htm

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    It isn't a cross browser script, it will only work on a couple of different browsers and even then it will only work properly on Internet Exploder. The Opera browser for example ignores ALL attempts to access the context menu from the web page. With Firefox that menu will display in addition to the proper contextmenu and will often end up behind the proper one where it can't be accessed and may as well not be there - the same would apply with Mozilla and Netscape.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a quick demo of how one might do this. Please keep in mind the advice given by felgall because he is absolutely correct.

  6. #6
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. Thanks for the help. That link you sent doesn't work in Firefox 2 though, so I'll just have to find another way to do the menu.

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works for me in FF2 as well as Opera. If by "doesn't work" you mean it doesn't cancel the browser's own context menu, then you evidently didn't read felgall's posts and you didn't even look at the demo's source code.

    You didn't ask for a way to cancel the browser's own context menu. You asked for a "homemade" context menu - and I showed you how to do it. I also showed you how to cancel the context menu in IE (which is the only browser in which you can do that) - but you evidently didn't bother to look.

    I think it would be best if you stuck with those copy-n-paste scripts at dynamicdrive.

  8. #8
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry I didn't clarify. What I meant by that post was that I do not want to spend anymore time on this. I thought it was something that could be done easily. Both you and felgall make it sound very unreliable, so I think I am going to just use a regular link instead of the fancy right click menu.

    Thank you very much for the help though.

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're welcome, cpellizzi. I apologize for being rude to you.

  10. #10
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found what I was looking for.. there is actually an oncontextmenu attribute for the anchor tag that I was unaware of.

  11. #11
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My demo uses oncontextmenu. But like we've already said - it is for IE only.


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
  •