Reputation: 261
I am working on a education based project wherein I am using <iframe>
to show some pdf
files for reading. I want to disable right click, cut, copy
and download
from the <iframe>
content which seems to be impossible. I have seen a few web portals in which all this features are embedded. I want to apply on mine too, can somebody tell how can this be implemented. Upon that, when I run the file on Firefox, it does not displays the iframe with PDF but it downloads automatically but it does displays on Chrome . I had been searching so many times but not yet able to stop above said issues. Any advice or suggestion would be highly appreciated.
<body>
<iframe id ="p" src="ppt1.pdf#toolbar=0" width="60%" height="70%" ></iframe>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var DEFAULT_URL = 'ppt1.pdf';
$(document).ready(function () {
$('#p').bind('cut copy paste', function (e) {
e.preventDefault();
});
$("#p").on("contextmenu",function(e){
return false;
});
});
</script>
</body>
Upvotes: 0
Views: 39
Reputation: 1306
Wouldn't adding an event listener for "contextmenu" to the iframe handle this? Search the web for "javascript disable right click" (without the quotes).
This has nothing to do with PHP.
Upvotes: 1