在浏览互联网时,用户可能会发现需要捕获某些内容以便向某人展示或展示,但有时网页上可能存在开发人员可能不希望用户对其进行屏幕截图的敏感信息。
用户可以按功能键以及Windows键和空格键来进行屏幕截图。在 MacOS 中,我们必须使用命令、shift 和 3 来截取屏幕截图。
在本文中,我们将了解如何阻止用户对网页进行屏幕截图。
如何阻止用户截图?
无法禁用截屏命令,因为这些是内置功能并由操作系统控制。我们可以使用 HTML、CSS 和 JavaScript,但仍然无法阻止用户截屏。阻止用户截图是一项艰巨的任务,因为用户可以复制粘贴网站内容,也可以使用一些第三方软件来做到这一点。
但是,我们可以通过一些方法来在一定程度上避免用户对网页进行截图。
示例
在下面的示例中,我们插入了一些文本,然后将其包含在 div 中,然后包含在 CSS 部分中。之后,我们使用媒体查询并将显示设置为无。这样,内容将对用户可见,但用户将无法打印屏幕。
<!DOCTYPE html> <html lang="en"> <head> <title>Example of disabling the printing </title> <style> @media print { html, body { display: none; } } </style> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
示例
在下一个示例中,我们将通过在屏幕上显示一条消息来警告用户不要复制或截图网页内容。
<!DOCTYPE html> <html lang="en"> <head> <title>Example of disabling the printing </title> <style> html { user-select: none; } </style> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
在上面的代码中,我们使用了与上一个示例中使用的相同段落,这次在 CSS 部分中,我们使用了 user-select 属性并将其值设置为 none。现在,用户将能够看到屏幕上的内容,但无法选择它。输出如下
示例
在下一个示例中,我们将通过在屏幕上显示一条消息来警告用户不要复制或截图网页内容。
<!DOCTYPE html> <html lang="en"> <head> <title>Example of printing a warning message to the user </title> <script> alert("Please!! do not try to take any kinds of screenshot of the content"); </script> </head> <body> <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html>
在上面的代码中,我们再次使用了相同的段落,并使用了 JavaScript 中的一行代码,如果用户尝试截取网页屏幕截图,这将会向用户发出警告。
结论
不可能完全阻止用户进行任何类型的屏幕截图或复制然后将您的内容粘贴到其他第三方网站上。打印屏幕是 Windows 和 MacOS 等每个操作系统都提供的内置功能,并且这些功能无法禁用,因为它们由操作系统控制。我们只能在一定程度上阻止用户复制内容,而不能超过此限度。
以上是是否可以阻止用户对网页进行截图?的详细内容。更多信息请关注PHP中文网其他相关文章!

这是我们在形式可访问性上进行的小型系列中的第三篇文章。如果您错过了第二篇文章,请查看“以:focus-visible的管理用户焦点”。在

CSS盒子阴影和轮廓属性获得了主题。让我们查看一些在真实主题中起作用的示例,以及我们必须将这些样式应用于WordPress块和元素的选项。

本教程演示了使用智能表单框架创建外观专业的JavaScript表单(注意:不再可用)。 尽管框架本身不可用,但原理和技术仍然与其他形式的建筑商相关。

构建内联文本编辑器并不是微不足道的。 该过程首先要使目标元素可编辑,并在此过程中处理潜在的语法异常。 创建您的编辑器 要构建此编辑器,您需要动态修改内容

Svelte Transition API提供了一种使组件输入或离开文档(包括自定义Svelte Transitions)时动画组件的方法。

本文探讨了Envato Market上可用的PHP表单构建器脚本,比较了其功能,灵活性和设计。 在研究特定选项之前,让我们了解PHP形式构建器是什么以及为什么要使用一个。 PHP形式

该教程通过使用node.js,express和multer构建文件上传系统来指导您。 我们将介绍单个和多个文件上传,甚至演示在MongoDB数据库中存储图像以进行以后的检索。 首先,设置您的projec


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Dreamweaver Mac版
视觉化网页开发工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。