最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable copy of selected portion of a webpage rendered by React application - Stack Overflow

programmeradmin2浏览0评论

I am trying to disable copy option for certain part of my webpage. I know that there is no way to disallow user to copy if he sets his mind to it but I just don't want a simple copy of certain section to not work (select + right click or ctrl+c) to work.

Is there a way to achieve it?

I am trying to disable copy option for certain part of my webpage. I know that there is no way to disallow user to copy if he sets his mind to it but I just don't want a simple copy of certain section to not work (select + right click or ctrl+c) to work.

Is there a way to achieve it?

Share Improve this question asked May 4, 2018 at 6:07 learnerlearner 1,9828 gold badges34 silver badges65 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

You can add the following styles to prevent the user from selecting the text superficially like so:

user-select: none;

p {
  user-select: none;
}
<p> Some sample text that you cant select </p>

Details on MDN

发布评论

评论列表(0)

  1. 暂无评论