'onContextMenu' Example : onContextMenu « Event Handlers Reference « JavaScript Reference

Home
JavaScript Reference
1.Event Handlers Reference
2.Javascript Collections
3.Javascript Methods
4.Javascript Objects
5.Javascript Properties
JavaScript Reference » Event Handlers Reference » onContextMenu 
'onContextMenu' Example

    
<html>
<head>
<script language="JavaScript">
    function function2() {
        alert("This image is copyrighted"
    }
</script>
</head>
<body oncontextmenu="function2()">
    <p>Right click in the image.</p>
    <img oncontextmenu="function2()" 
         src="http://www.java2s.com/style/logo.png" 
         alt="" 
         width="99" 
         height="76">
</body>
</html>
If you want to prevent the user from opening the context menu, 
add the following code to the <body> element above:
oncontextmenu="function2(); return false;"

    
      
      
Related examples in the same category
1.'onContextMenu' Syntax and Note
2.'onContextMenu' Properties
3.'onContextMenu' is applied to
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.