Home > Article > Web Front-end > How to prohibit copy and paste in html
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. .
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!