Page 1 of 1

Validating JavaScript trigger BEFORE contextmenu triggers?

Posted: Fri Jan 27, 2006 1:14 pm
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

Posted: Fri Jan 27, 2006 1:51 pm
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..

Posted: Fri Jan 27, 2006 2:28 pm
by JAB Creations
How do I reference the contextmenu via JavaScript? if (__whatisreference__ = true) {} ?

Posted: Fri Jan 27, 2006 3:01 pm
by feyd
I shouldn't have been all that hard to find on your own:

Google: context menu javascript

Posted: Fri Jan 27, 2006 3:50 pm
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