View Full Version : Right click menu help?

05-10-2008, 12:10 AM
Hi i have a webpage with output from a database with all name like:


and i want to use this context menu on it: http://www.dynamicdrive.com/dynamicindex1/contextmenu.htm

so when i right click on 1 of the names on the page it shows up, so if i right click on the word fred the menu would say Fred in 1 of the links, how would i do that?

05-10-2008, 03:45 AM
You wouldn't. That script is too outdated to use for anything in the real world. This is because most modern browsers will no longer allow the co-opting of the default context menu.

It was a bad idea to begin with in my opinion, even when it did work, because users often depend upon their context menus, and if they do, don't appreciate it when it is taken away from them.

05-10-2008, 04:16 AM
is there a script out there that can?

05-10-2008, 05:16 AM
Not that I know of. Browsers not allowing this type of thing has nothing to do with the particular script used.

05-10-2008, 08:35 AM
I cannot complete the site without one i jsut need it to work in ie or firefox thats all.

05-10-2008, 03:31 PM
IE, perhaps - depending upon settings and version. FF, no. I'm not going to discuss this much further except to say:

It's a bad idea for reasons I already mentioned.
Your site should work fine without javascript anyway.
There is always another way to get the sort of navigational functionality you are looking for without co-opting the user's browser. It might not look like you originally thought, but it will work out.

Unless of course you want to look into alternative means to set up your site so that it will not need this, but will still convey the navigational flow you intend. For that though, you should open a new thread, probably either in the HTML or Javascript forums.

One thought that comes to mind is a select element.

05-10-2008, 05:03 PM
You would need to attach a on click event listener to the document. This would catch the mouse button 2 click, cancel it (event), then display a DIV element simulating a right click menu. This however would not be a good solution for user navigation since no one right clicks except to view the source or save a image/file.