当前位置:网站首页>Prohibit copying content in web pages
Prohibit copying content in web pages
2022-04-22 17:13:00 【When there's not enough time】
<body>
Used to test whether the page content can be copied
</body>
Method 1
add to JavaScript function , Disable right clicking and Ctrl+C
<script type="text/javascript">
document.oncontextmenu = function(){
return false
}
document.onkeydown=function(ev){
var ev=window.event||ev;
if((ev.ctrlKey) && (ev.keyCode==67)){
ev.returnValue=false;
}
}
</script>
Method 2
stay body Add oncontextmenu and onselectstart attribute , Or in script Add a function to the tag to set its properties
<body oncontextmenu="event.returnValue=false" onselectstart="event.returnValue=false">
</body>
or
<body oncontextmenu="return false" onselectstart="return false">
</body>
or
<script language="Javascript"> document.oncontextmenu=new Function("event.returnValue=false"); document.onselectstart=new Function("event.returnValue=false"); </script>
Method 3
Disable right click menu 、 Copy 、 choice , Use jquery The way
<script type="text/javascript">
$(document).bind("contextmenu copy selectstart", function() {
return false;
});
</script>
Method four
css Methods
body {
-moz-user-select:none; /* Firefox Private property */
-webkit-user-select:none; /* WebKit Kernel private properties */
-ms-user-select:none; /* IE Private property (IE10 And later ) */
-khtml-user-select:none; /* KHTML Kernel private properties */
-o-user-select:none; /* Opera Private property */
user-select:none; /* CSS3 attribute */
}
The point is that
topmargin="0"
οncοntextmenu="return false"
οndragstart="return false"
onselectstart ="return false"
οnselect="document.selection.empty()"
οncοpy="document.selection.empty()"
onbeforecopy="return false"
οnmοuseup="document.selection.empty()"
版权声明
本文为[When there's not enough time]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221712242525.html
边栏推荐
- Opendaylight analysis of SDN learning (1)
- How does glboalmapper20 convert hundreds of longitude and latitude projected images into national 2000 or other projected images at one time
- Opendaylight analysis of SDN learning (2)
- OJ daily practice -- find the sum of score sequences
- Ansible of operation and maintenance automation -- (playbook mode)
- 全网征集!说说你跟宜搭之间的故事吧
- Hybrid Backpack
- Triple pressure of Xiaoxiong electric appliance: expansion, inventory and competitors
- Introduction to webrtc: 4 Rtcpeerconnection connects audio and video streams
- PHP通过FTP上传、下载
猜你喜欢

webrtc入门:4.RTCPeerConnection连接音视频流
![[distributed project] certification service center, social login oauth2 0. Single sign on and distributed session solutions](/img/b5/c4fb21101a8d4b83de760d0feda296.png)
[distributed project] certification service center, social login oauth2 0. Single sign on and distributed session solutions

小熊电器的三重压力:扩张、存货和对手

Detonate the most bombs - C language DFS recursive approach

ASP.NET Core实现JWT授权与认证(2.实战篇)

2022 EIA Engineer Examination case analysis exercises and answers

Redis (16) -- redis cluster

2022年湖南省初级会计职称考试经济法基础练习题及答案

ES6 Proxy和Object.defineProperty

關於閉包的7道面試題
随机推荐
MySQL配置sql_mode
数组对象拼串
Redis(16) -- Redis集群
Practice questions and answers of evaluation technical methods in 2022 environmental impact assessment engineer examination
ES6 Generator函数和async函数
Add release configuration in clion
關於閉包的7道面試題
List to map and duplicate key md
2022年环境影响评价工程师考试相关法律法规练习题及答案
混合背包呀
How to efficiently manage data in a hybrid cloud?
7 interview questions about closure
面向全球市场,PlatoFarm今日登录HUOBI等全球四大平台
关于微信小程序中,解决有tabbar时,键盘弹起引起的空白区域问题
MySQL配置参数和命令
使用apexcharts组件的折线图(smooth的面积曲线)
非线性优化问题---MATLAB
Regular matching URL
[Dahua cloud native] wonderful relationship between message queue and express cabinet (with video)
How can we make the calendar note of win10 computer display 24 solar terms?