Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture right click target

Status
Not open for further replies.

elliottmina

Programmer
Feb 6, 2005
12
0
0
US
Is there any way to capture a user's right click behaviour, including what option they chose. For example, I right click on a link, and choose "save as". I want to tie a javascript function to that action.

Thanks!
 
Alas, I do not believe so. I'd love to be shown that I'm wrong about this though.

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
The save as function is executed within the security context of the local PC so it is locked from access through web code as it has the ability to write to the local PC and would otherwise be a major security issue.

You CAN detect the right click and suppress the context menu or even cause your own custom menu to come up in it's place but to create your own custom Save As function in it would require ActiveX which would cause security warnings for the end-user and it would only work in IE.



Stamp out, eliminate and abolish redundancy!
 
theniteouwl;

can you post an example of how to capture the right-click for us, then?




I hope this helps;
Rob Hercules
 
I have no sample code but just search on right click context menu and you will see some.

Testing for clicks is not very standard across the browsers so you have to get into some fancy code to accomodate all the browsers.



Stamp out, eliminate and abolish redundancy!
 
This will work in IE:

Code:
<body oncontextmenu='return false;'>

The "return false" prevents the menu from showing up.

If you want to call a function as part of this action, you must do it before the return statement.

When in that function (if using IE), just call on one of the event properties. For example, event.type will return "contextmenu".

'hope that helps some.

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top