Home  >  Article  >  Web Front-end  >  How to prohibit copy and paste in html

How to prohibit copy and paste in html

青灯夜游
青灯夜游Original
2021-05-14 16:16:087901browse

In HTML, you can use the touch-callout and user-select attributes to prohibit the copy and paste function. You only need to set the "user-select:none;-webkit-touch-callout:none;" style. .

How to prohibit copy and paste in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

My friends occasionally encounter such a demand when developing. The customer requires that copying and pasting be prohibited on the article page. The code to implement this function is as follows (can be implemented on both PC and mobile terminals):

*{

-webkit-touch-callout:none; /*系统默认菜单被禁用*/

-webkit-user-select:none; /*webkit浏览器*/

-khtml-user-select:none; /*早期浏览器*/

-moz-user-select:none;/*火狐*/

-ms-user-select:none; /*IE10*/

user-select:none;

}

After adding this code, there will be a problem on IOS. At this time, you will find that the input box cannot input content; the reason for this is the -webkit-user-select:none; attribute. .

The solution to this problem is to set the input attributes in the css file at the same time, as shown below:

input {

-webkit-user-select:auto; /*webkit浏览器*/

}

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to prohibit copy and paste in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn