I can't disable Copy, Cut, Paste and Right Click actions for PDF inside iframe
my code for the iframe
<iframe id="pdfViewer" src="url-pdf.pdf#toolbar=0&navpanes=0&scrollbar=0" title="Title PDF" frameborder="0" scrolling="auto" class="no-right-click no-cut-copy-paste" height="400px" width="100%" style="border: 30px solid #EEE"></iframe>
I've tried many solutions, but no one is work for me
Some solution I've tried using
1. css:
.no-cut-copy-paste {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
2. Javascript
var pdfViewer = document.getElementById('pdfViewer');
pdfViewer.window.eval('document.addEventListener("contextmenu", function (e) {e.preventDefault();}, false)');
$(document).on('cut copy paste', '.no-cut-copy-paste', function(e) {
e.preventDefault();
return false;
});
3. jQuery
$('#pdfViewer').attr('contextmenu', 'return false')
But there is work for all pages of my application, but the right click is still active on iframe
document.oncontextmenu = function() {
return false;
};