How to implement prohibition of html selection: 1. Prohibit html content from being selected through css; 2. Prohibit html content from being selected by adding onselectstart and other attributes to the body tag; 3. Through js Add onselectstart statement to implement prohibition.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
In the page, html content is prohibited from being selected
1. Through css
*{ moz-user-select: -moz-none; -moz-user-select: none; -o-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -ms-user-select:none; user-select:none; }
user-select attribute: refer to https://www.html.cn/book /css/properties/user-interface/user-select.htm
2. By adding the following attributes to the body tag:
The first sentence prohibits right-clicking, and the latter sentence prohibits copying. of.
3. Add the following two lines of statements in js:
//禁止页面选择以及鼠标右键 document.function(){return false;}; document.onselectstart=function(){return false;};
[Recommended learning:HTML video tutorial]
The above is the detailed content of How to implement prohibition of selection in html. For more information, please follow other related articles on the PHP Chinese website!