javascript 防止右键单击 <iframe>,其中 iframe 在 Internet Explorer 中包含 PDF 文件(严格为 IE)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13739984/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Prevent right click on <iframe> where an iframe contains PDF file in Internet Explorer(IE strictly)
提问by ameya rote
Possible Duplicate:
Prevent PDF file from downloading and printing
可能的重复:
防止下载和打印 PDF 文件
I kow we have lots of post to prevent right click on ,
我知道我们有很多帖子可以防止右键单击,
here i'm trying to have an containing PDF where user cannot right click on the pdf for Internet Explorer browser.
在这里,我正在尝试包含一个包含 PDF 的 PDF,其中用户无法右键单击 Internet Explorer 浏览器的 pdf。
The basic idea is to prevent user from copying or printing the pdf file.
基本思想是防止用户复制或打印 pdf 文件。
I have done following code it works on chrome, but fails badly on IE. FYI - PDF file is on same Domain
我已经完成了以下代码,它适用于 chrome,但在 IE 上失败了。仅供参考 - PDF 文件在同一个域中
<html>
<head>
<title>Disable Context Menu</title>
<script type="text/jscript">
function disableContextMenu()
{
window.frames["fraDisabled"].document.oncontextmenu = function(){alert("Right Click disabled!"); return false;};
// Or use this
// document.getElementById("fraDisabled").contentWindow.document.oncontextmenu = function(){alert("Right Click disabled!"); return false;};;
}
</script>
</head>
<body bgcolor="#FFFFFF" onload="disableContextMenu();" oncontextmenu="return false">
<iframe id="fraDisabled" width="528" height="473" src="landscape.pdf#toolbar=0&navpanes=0" onload="disableContextMenu();" onMyLoad="disableContextMenu();"></iframe>
</body>
</html>
Or is there any other to protect your pdf file working on IE ?
或者还有其他方法可以保护您在 IE 上运行的 pdf 文件吗?
回答by Akhil Sekharan
One way you can do it is to unbind all the mouse events. Would't be the best way. And I agree with ahren
一种方法是解除所有鼠标事件的绑定。不会是最好的方法。我同意 ahren
<iframe id="fraDisabled" style="pointer-events:none;" src="landscape.pdf#toolbar=0&navpanes=0"/>
回答by Ma9ic
You could always use something like http://pageflip.hu/and create the file into a SWF or onto a video to deter people from copying it easily, but as "ahren" said if you can see it you can copy it.
您始终可以使用类似http://pageflip.hu/ 的内容并将文件创建为 SWF 或视频以阻止人们轻松复制它,但正如“ahren”所说,如果您能看到它,您就可以复制它。