使用 javascript 在所有浏览器中禁用保存和另存为选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10446585/
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
Disable Save & Save As option in all Browsers using javascript
提问by user1350766
I want to disable Save As and Save options in all browsers (like Internet Explorer, Chrome, Firefox, Opera, etc). I have already disabled right click on my web page. The code is here:
我想在所有浏览器(如 Internet Explorer、Chrome、Firefox、Opera 等)中禁用另存为和保存选项。我已经禁用了在我的网页上单击鼠标右键。代码在这里:
var message="Function Disabled!";
function clickIE4()
if(event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if(document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if(document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
回答by Quentin
I want to disable save as and save options in all Browsers,
我想在所有浏览器中禁用另存为和保存选项,
You can't.
你不能。
i have already disable right click
我已经禁用右键单击
Not very effectively.
不是很有效。
DRM doesn't work well in systems that are designed to support it (e.g. DVD players). It is much less effective in systems that are not designed to support it (e.g. web browsers).
DRM 在旨在支持它的系统(例如 DVD 播放器)中不能很好地工作。在不支持它的系统(例如 Web 浏览器)中,它的效率要低得多。
回答by st-boost
By opening your webpage the user has already downloaded it - it is impossible to make a webpage that can be viewed, but not saved.
通过打开您的网页,用户已经下载了它 - 不可能制作一个可以查看但不能保存的网页。
Of course, you can block some methods, as you have - you can even use some complex ajax or flash to really screw with them. But in the end there will always be a way around it. I suggest you look for a different approach to keeping your data where you want it. For example, if the issue is that people are "stealing" your images, you could watermark them.
当然,您可以像以前一样阻止某些方法 - 您甚至可以使用一些复杂的 ajax 或 flash 来真正搞砸它们。但最终总会有办法绕过它。我建议您寻找一种不同的方法来将数据保存在您想要的位置。例如,如果问题是人们“窃取”您的图像,您可以给它们加水印。