8

我们如何限制用户保存页面?

请提供一些提示来禁用文件->保存和查看源选项

编辑:显然它不能完成,并且可能不应该尝试。但可能这个问题的一个更有趣的变体是,我们如何才能让用户很难以可用的格式保存页面,以至于他们这样做不值得?这个问题没有任何价值,而是说我们正在保护一个文章订阅网站,用户每年要支付几百美元才能继续访问文本。

4

11 回答 11

55

由于页面已发送给客户端,因此总会有一种方法可以获取该信息。试图阻止用户这样做只会让他们感到沮丧。

让用户无法保存文件的唯一方法是不将其发送给他们。

于 2009-03-05T18:33:07.607 回答
15

虽然最好的答案是“不要这样做”,但有一些方法可以让他们更难做到。而且由于该站点的重点实际上是回答问题,即使它很糟糕,这里是最好的方法:

首先,您需要在新窗口中打开页面,在该窗口中关闭地址栏和工具栏以及其他所有内容。这将使用户根本无法轻易进入“文件”菜单。为此,您需要用户加载到的“启动”页面,然后当他们单击链接时,它会打开提供页面主要内容的弹出窗口。关于如何在没有工具栏之类的情况下创建弹出窗口的详细信息在这里: http ://blazonry.com/javascript/windows.php

然后,您需要向每个页面添加一些 javascript,以防止用户右键单击。这是一种方法:http: //javascript.about.com/library/blnoright.htm

最后,如果您不希望看到您的 Javascript 代码,那么混淆您的代码是一种非常有效的方法。如果他们有很多专业知识,他们仍然可以看到代码,但是混淆的代码将是一个巨大的痛苦来实际解释。那里有很多混淆器。这是一个免费的基于网络的: http ://www.javascriptobfuscator.com/

这远非万无一失。它将阻止所有“临时”用户,但任何高级用户都可能能够轻松找到解决方法。不过,如果这个想法是为了至少阻止其中的大部分,那么这应该就足够了。

更新问题的更新: 为了解决您的新扩展问题,我想说完成您所说的最佳方法是使用支持 DRM 的格式。Adobe Acrobat 可能是最佳选择,因为几乎每个人都安装了阅读器。您可以阻止将 PDF 文件保存到计算机,以便它们只能由登录用户从网页加载。用户仍然可以对文档本身进行屏幕截图,我认为这是不可预防的(除非 Adob​​e Reader 对此有一些安全措施,他们可能会这样做),但对于大多数用途来说,它应该是足够的安全性。

于 2009-03-05T18:39:27.387 回答
11

不要这样做。

说真的,如果用户可以在他们的浏览器中看到该页面,他们就可以看到源代码和/或将其保存到他们的计算机上。

你在这里打了一场失败的战斗。

于 2009-03-05T18:34:09.053 回答
4

It's really a waste of time and resources to try and do this in html as any method you use can be trivially circumvented.

Instead I would use some other technology to display the data - you can never get around a screen capture. but if you're for instance displaying text and you want to make it hard for the use to save that text for use elsewhere then possible options include

  1. PDF - which can disable save and print. There are extensions to most popular web languages that will write a pdf on the fly. Indeed you might be as well just to go down the DRM route with Adobe and embed a document

  2. Flash - most probably via Flex which could be used to write a general-purpose app to display text and images. The advantage of Flash is that it's easier to set up links than pdf.

  3. Or something else, a custom java applet, or even a vrml plugin and display the text in 3D!

In all cases you could display text against a disruptive background to make OCR more difficult, and images could be watermarked. However nothing is going to stop a determined and resourceful viewer, although you can possibly make it sufficiently hard that it's not worth their time.

于 2009-03-05T19:06:20.507 回答
4

浏览器的缓存呢?它可以从那里保存。

打印屏幕呢?这也可以保存页面。

阻止用户保存某些内容的唯一方法是首先不向他们显示。

于 2009-03-05T18:33:59.227 回答
2

The least you can do is... the content is generated dynamically by Javascript. In that way, they cannot simply save it. Of course, in FX, they can still view the generated code and then copy&paste. however, normally people cannot save the page.

于 2009-03-05T19:07:49.067 回答
1

这应该不是问题,但是如果您出于某种原因真的不希望用户看到您的代码(javascript、css 或 html),那么您可以使用一些混淆工具来降低代码的可读性。

于 2009-03-05T18:41:05.200 回答
1

尝试javascript“编码”和混淆。

就像是

if(document.location == 'mydomain.com') {
  content = getAjax('mycontent.xml');
  // content will hold something like 72, 94, 81, 99, ... - encoded ASCII codes
  document.write(String.fromCharCode(content));
}

总是可以保存页面,但对于非技术人员来说,使其工作更加困难。有2个保护

  • 域名
  • 转换 ASCII

这只是伪代码,但我想你明白了。

于 2009-03-06T18:06:09.283 回答
0

将这些添加到脚本标记中的代码集

document.addEventListener('contextmenu', function (e) {
                e.preventDefault();
});

document.onkeydown = function (e) {
                return false;
};
于 2018-12-01T15:33:15.110 回答
-1

我想再添加一种方法,恕我直言,很难规避:Ctrl+S!(对我来说,Apple+S)

于 2009-06-20T07:07:24.883 回答
-1

我们如何才能让用户以可用的格式保存页面已经足够困难,以至于他们这样做是不值得的

没什么难的:在每一页上添加:“John Stealer 的个人财产,Zetabeta 公司,用信用卡支付 756890987654,账单地址......,订阅将于 12/20 到期”。

这是我刚刚发明的“扩展文本格式”……它有一个惊人的特性:虽然它看起来像普通文本,但用户不太愿意将其打印出来并提供给其他人……

于 2009-06-20T07:11:26.450 回答