Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Can any one have idea how to disable right click on pdf which is embedded in iframe.

I am using this:
C#
$(document).bind("contextmenu", function (e) {
        return false;
    });


but it is disabling the rightclick only other part of webpage not on iframe.

Please help me. Thanks in advance!!
Posted
Updated 11-Nov-17 12:44pm

1 solution

<script type="text/javascript">
document.onmousedown = disableRightclick;
var message = "Right click not allowed !!";
function disableRightclick(evt){
    if(evt.button == 2){
        alert(message);
        return false;    
    }
}
</script>
 
Share this answer
 
Comments
venkatesh chitteti 11-Feb-19 6:45am    
Perfectly working thank you for your code.
You saved my time.
dixit himanshu 22-Jul-21 11:14am    
Not working, but thanks for the help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900