HTML禁止复制粘贴以及禁止下载图片的小技巧
来源:互联网 发布:淘宝订单能删除吗 编辑:程序博客网 时间:2024/05/21 19:43
一、禁止复制文字代码
<body leftmargin=0 topmargin=0 oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>
二、真正的屏蔽鼠标右键
<script language="JavaScript">
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>
三、
<SCRIPT LANGUAGE=javascript>
function click() {alert('禁止左键复制!') }
function click1() {if (event.button==2) {alert('禁止右键点击~!') }}
function CtrlKeyDown(){if (event.ctrlKey) {alert('非法拷贝将损害您的系统!') }}
document.onkeydown=CtrlKeyDown;
document.onselectstart=click;
document.onmousedown=click1;
</SCRIPT>
把上面的代码放到</head> 与<body> 之间我已经调试过了 没问题
禁止保存网页
<NOSCRIPT><IFRAME src=Example132.htm></IFRAME></NOSCRIPT>
下面这段代码,就能搞定在网页中又禁止复制、又禁止键盘复制、还能禁止选择。
<script language="Javascript">
document.oncontextmenu=new Function("event.returnValue=false");
document.onselectstart=new Function("event.returnValue=false");
</script>
四、
onselect="document.selection.empty()"//禁止选中
oncopy="document.selection.empty()"//禁止复制
下面给你个演示:
<html>
<head><title>禁止右键和禁止使用复制键</title>
<script language="javascript">
function onKeyDown()
{
if ((event.keyCode==116)||(window.event.ctrlKey)||(window.event.shiftKey)||(event.keyCode==122))
{
event.keyCode=0;
event.returnValue=false;
}
}
function yxl() {
if(window.event.altKey)
{
window.event.returnValue=false;
}
}
document.onkeydown=yxl ;
</script>
</head>
<!--在网页中加上下面代码//-->
<body onkeydown="onKeyDown()" oncontextmenu="return false">
嘿嘿,把我复制走吧,我跟你拉!呵呵
</body>
</html>
五、
禁止复制代码
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body leftmargin=0 topmargin=0 onmousemove='HideMenu()' oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()"><noscript><iframe src="/*>";</iframe></noscript>
禁止下载图片:
可以做双层保护第一,oncontextmenu="return false"放在<body>里 例子:<body oncontextmenu="return false" bgcolor="808080" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >作用:简单的方式右健弹出第二,现在IE或者QQ浏览器都有自己的IE插件 鼠标放到图片会有插件提示你保存解决办法:方法一(针对单独的图片):方法二(针对整个页面中的图片有效):<meta http-equiv="imagetoolbar" content="false">这样的话可以做双层保护的oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴oncontextmenu="return false" :禁止右键onselectstart="return false" : 禁止选取onpaste = "return false" : 禁止粘贴oncopy = "return false" : 禁止复制oncut = "return false" : 禁止剪贴
0 0
- HTML禁止复制粘贴以及禁止下载图片的小技巧
- HTML技巧:怎样禁止图片拖动复制
- 屏蔽右键/禁止复制和粘贴 --几个JS小技巧
- 屏蔽右键/禁止复制和粘贴 --几个JS小技巧
- 禁止 UITextField 的粘贴、复制
- javascript 禁止右键,禁止复制,禁止粘贴
- HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法;
- 禁止复制粘贴
- javaScript禁止粘贴复制
- JavaScript-禁止复制、粘贴
- JS禁止复制粘贴
- Edittext禁止复制粘贴
- EditText禁止复制粘贴
- 禁止复制粘贴
- html实现 页面禁止右键 禁止复制 禁止图片拖动 禁止复制和剪切
- 页面禁止复制和粘贴的代码
- 禁止文本框的复制和粘贴功能
- js 小技巧 禁止复制页面
- js中的事件触发(非常详细)
- JDBC驱动问题
- 服务端socket
- weka 交叉验证
- 转载别人的一些经验
- HTML禁止复制粘贴以及禁止下载图片的小技巧
- 112.模拟杀毒软件小火箭
- Ruby 安装
- centos6.5ip分配以及用户和用户组的操作
- marchine learning 斯皮尔曼排名相关系数
- XAMPP下更改时区或者时间与本地时间相差固定小时
- 0和5
- mpu6050的安卓驱动分析
- AndroidStudio2.2进行NDK开发