热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何防止用户从我的网页中选择和复制文本-Howtopreventuserfromselectingandcopyingtextfrommywebpage

Iknowthatwecanusejavascripttoachievethisbutdisablingthejavascriptinthewebbrowser,u

I know that we can use Javascript to achieve this but disabling the Javascript in the web browser, user can easily copy text. Is there any way for this using CSS?

我知道我们可以使用Javascript来实现这一点但是在Web浏览器中禁用Javascript,用户可以轻松地复制文本。有没有办法使用CSS?

8 个解决方案

#1


9  

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

#2


31  

If you don't want someone copying your text, don't place it on the web.

如果您不希望有人复制您的文本,请不要将其放在网上。

The web's source is visible, free to read, and to copy.

网络的来源是可见的,可以自由阅读和复制。

Even with all the CSS, Javascript or imagary tricks you may pull off, nothing will prevent a user from manually reading and copying your text to a different document/location.

即使你可以使用所有的CSS,Javascript或想象技巧,也不会阻止用户手动阅读和将文本复制到不同的文档/位置。

The best you can probably hope to do is to annoy people enough to discourage them from copying your text. But like all other things, someone persistent would be able to pull it off.

你可能希望做的最好的事情是惹恼别人,以阻止他们复制你的文字。但就像所有其他事情一样,持之以恒的人能够将其拉下来。

That's what us humans do.

这就是我们人类所做的事情。

#3


8  

There's no way to stop someone sufficiently determined from copying the text of your website. Even if there was some hypothetical perfect way of blocking copying and pasting or downloading the pages to only be viewed and not saved (which there isn't), someone with enough time and motivation can just type out the text by hand if they really wanted it.

没有办法阻止某人充分决定复制您网站的文字。即使有一些假设完美的方法来阻止复制和粘贴或下载页面只能被查看而不能保存(没有),有足够时间和动力的人可以手动输入文本,如果他们真的想要的话它。

The web is designed to be open. And a good thing that it is too. Extracting the data from a web page authored in 1991 isn't particularly difficult. Try doing the same thing with a Microsoft Word document from the same era without using a Microsoft product.

网络设计为开放式。它也是一件好事。从1991年创作的网页中提取数据并不是特别困难。尝试使用同一时代的Microsoft Word文档执行相同操作,而不使用Microsoft产品。

#4


5  

Similar question here with some good answers so I won't cover old ground

类似的问题在这里有一些好的答案,所以我不会涵盖旧的理由

Whatever you do, the user is still going to be able to view the source of the page and copy anything from there. The only way to totally prevent it is not to display any text at all (e.g. display an image, or dynamically create an image which isn't great for accessibility)

无论你做什么,用户仍然可以查看页面的来源并从那里复制任何内容。完全阻止它的唯一方法是根本不显示任何文本(例如显示图像,或动态创建不适合可访问性的图像)

#5


2  

The web is open source, free to read, there is no way to warn people to copy content even with java script but you can warn via CSS. trick like below.

网络是开源的,可以自由阅读,即使用java脚本也无法警告人们复制内容,但你可以通过CSS发出警告。诀窍如下。

Try this...

尝试这个...

p
{
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#6


2  

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

This is a good way to prevent user from selecting text. And this is not a bad answer. For instance, if you work on a website that uses Canvas (HTML5) and allows users to drag'n'drop stuff on this canvas; if the user is going out of canvas defined zone, text will start to get 'selected'. Which is ugly. So for obvious ergonomic reasons, this is a good way to go.

这是防止用户选择文本的好方法。这不是一个糟糕的答案。例如,如果你在一个使用Canvas(HTML5)的网站上工作,并允许用户在这个画布上拖动东西;如果用户离开画布定义区域,文本将开始“选中”。这很难看。因此,出于明显的人体工程学原因,这是一个很好的方法。

#7


0  

What your client, and many others, are looking for is not possible, because they don't understand how web pages are transmitted, but, these clients will probably be happy with making it "difficult" for a user to copy the text. There are other use-cases where text that could be marked as not copyable would be a useful feature, for example, you want to make it easy for a user to copy some text without copying something that makes no sense to copy, like metadata, for example a time stamp.

您的客户和其他许多人正在寻找的是不可能的,因为他们不了解网页的传输方式,但是,这些客户可能会很高兴让用户“难以”复制文本。还有其他一些用例,其中可以标记为不可复制的文本将是一个有用的功能,例如,您希望用户可以轻松复制某些文本而无需复制无法复制的内容,如元数据,例如时间戳。

As far as the previous answers, they seem to indicate the way to do this with css is with the user-select css property, however, this keeps the text from appearing to be selected, but it will still copy to the clipboard. However, that is the best you will get with css alone and might dissuade some users from copying your content.

就前面的答案而言,它们似乎表明使用css的方法是使用用户选择的css属性,但是,这样可以防止文本被选中,但它仍然会复制到剪贴板。但是,这是单独使用css时最好的,可能会阻止某些用户复制您的内容。

Javascript will take it one step further and make it difficult to copy from the browser window without using developer tools.

Javascript将更进一步,并且难以在不使用开发人员工具的情况下从浏览器窗口进行复制。

#8


0  

-webkit-touch-callout: none; ;
-webkit-user-select: none;
-khtml-user-select: none; 
-moz-user-select: none;
-ms-user-select: none; 
user-select: none;

The text won't be selected but, We can copy the text in some cases.

文本将不会被选中,但我们可以在某些情况下复制文本。


推荐阅读
  • 涉及的知识点-ViewGroup的测量与布局-View的测量与布局-滑动冲突的处理-VelocityTracker滑动速率跟踪-Scroller实现弹性滑动-屏幕宽高的获取等实现步 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 使用eclipse创建一个Java项目的步骤
    本文介绍了使用eclipse创建一个Java项目的步骤,包括启动eclipse、选择New Project命令、在对话框中输入项目名称等。同时还介绍了Java Settings对话框中的一些选项,以及如何修改Java程序的输出目录。 ... [详细]
  • 本文介绍了解决mysql 5.1启动问题的方法,通过修改my.ini文件中的相关配置,包括innodb_data_home_dir和skip-innodb等,可以解决启动问题。同时还介绍了如何调整内存池来存储metadata信息。 ... [详细]
  • 关于extjs开发实战pdf的信息
    本文目录一览:1、extjs实用开发指南2、本 ... [详细]
  • html结构 ... [详细]
  • Apple iPad:过渡设备还是平板电脑?
    I’vebeenagonizingoverwhethertopostaniPadarticle.Applecertainlydon’tneedmorepublicityandthe ... [详细]
  • Android仿微信右滑返回功能的实例代码
    Android仿微信右滑返回功能的实例代码-先上效果图,如下:先分析一下功能的主要技术点,右滑即手势判断,当滑到一直距离时才执行返回,并且手指按下的位置是在屏幕的最左边(这个也是有 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • 1.webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用(1) ... [详细]
  • HTC EVO 4G+手机存储(SD卡)中各个文件夹功能说明(转载)
      HTCRider/X515E/EVO4G+手机存储(SD卡)中各个文件夹功能说明  HTCRider/X515E/EVO4G+  1、.android_s ... [详细]
author-avatar
最美的你
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有