Validating JavaScript trigger BEFORE contextmenu triggers?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Validating JavaScript trigger BEFORE contextmenu triggers?

Post by JAB Creations »

I'd like to return false and cancel the contextmenu via JavaScript on certain anchors. Since "oncontextmenu" does not validate I know I have to call a function. Problem is I do not know which events trigger BEFORE the contextmenu triggers. Then I'm going to throw in an alert but I can do that!

Right now I have something like this...

Code: Select all

<script type="text/javascript">
//<![CDATA[
function oncontextmenu(event) {alert ("Alert");return false;}
//]]>
</script>

Code: Select all

<a href="#" onmouse?????="preview();">link</a>
What can we do to achieve this and stay within the boundaries of validation?

John
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

onclick is the event fired. You have to look at the event trigger details to determine if it's a context menu or not..
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

How do I reference the contextmenu via JavaScript? if (__whatisreference__ = true) {} ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I shouldn't have been all that hard to find on your own:

Google: context menu javascript
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

One of my few but constant goofs. Firefox allows one to disallow contextmenu manipulation without disabling JavaScript altogether.

Works fine now. :D
Post Reply