Please Any one can help me for solving this problem.I want to my web page show pdf file using Ifram, but i want just disable right click on ifram.
My Code is Bellow
$(document).contextmenu(function () {
return false;
});
<iframe id="pdf" src="<?= base_url('assets/uploads/' . $notice['file']); ?>#toolbar=0&scrollbar=0&navpanes=0&embedded=true&statusbar=0&view=Fit;readonly=true;disableprint=true;"
style="width:100%; height:900px;" frameborder="0"></iframe>
You can try this in javascript
<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
</script>
But anyways any Javascript you code can be rendered mute by simply turning off Javascript on the browser.
Additionally, there's no way to disable the ability of any user to simply "view source" or "view page info" for your site and get what they want.
Hope the code helps you, and you reconsider disabling right click.
One more way in JS :
document.addEventListener("contextmenu", function(e){
e.preventDefault();
}, false);
Also, your code looks like JQuery, so here's JQuery example :
$(function() {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});