html禁止选择的实现方法:1、通过css的方式实现禁止html内容被选中;2、通过在body标签中添加onselectstart等属性实现禁止html内容被选中;3、通过在js中添加onselectstart语句实现禁止。
本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
页面中,禁止html内容被选中
1、通过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属性:参考https://www.html.cn/book/css/properties/user-interface/user-select.htm
2、通过在body标签中添加如下属性:
<body "return false;" onselectstart="return false">
前面一句是禁止右键的,后面一句是禁止复制的。
3、在js中添加如下两行语句:
//禁止页面选择以及鼠标右键 document.function(){return false;}; document.onselectstart=function(){return false;};
【推荐学习:HTML视频教程】
以上就是怎么实现html禁止选择的详细内容,更多请关注美工之家9502669.com其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。