禁止鼠标各种操作的代码
2012-09-05 14:03
423 查看
document.onselectstart =function() {return false;} // 防选择
document.oncopy =function() {return false;} // 防复制
document.oncut =function() {return false;} // 防剪贴
document.onbeforecopy =function() {return false;}
document.ondragstart =function() {return false;} //防拖动
document.oncontextmenu =function() {return false;} //防右键
document.onmouseup =function() {document.selection.empty();}
document.onselect =function() {document.selection.empty();}
document.oncopy =function() {document.selection.empty();}
document.onmousedown =function() {if (event.button!==1){alert('禁止操作');}}
document.onkeydown =function() {alert("禁止操作");event.keyCode=0;event.returnValue=false;}
// 屏蔽PrintScreen
function testclip(){
try {
if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL")) //检测系统内存
{
null; //不为图像则保留内存
}
}
catch(e){
clipboardData.setData("Text","")//清空内存
}
setTimeout("testclip()",500)
}
testclip();//不停清空剪贴板
// 禁止打印
@media print{
body{display:none}
}
// 禁止保存
<noscript>
<iframe src="*.htm"></iframe>
</noscript>
// 禁用右键
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
禁用
window.ClearEvent=function(){event.cancelBubble=false;
var sSrcTagName=event.srcElement.tagName.toLowerCase();
return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");}
window.ClearKey=function(){event.cancelBubble=false;var iKeyCode=event.keyCode;return !(iKeyCode==78 && event.ctrlKey);}
with (window.document){oncontextmenu=onselectstart=ondragstart=window.ClearEvent;onkeydown=window.ClearKey;}
document.oncopy =function() {return false;} // 防复制
document.oncut =function() {return false;} // 防剪贴
document.onbeforecopy =function() {return false;}
document.ondragstart =function() {return false;} //防拖动
document.oncontextmenu =function() {return false;} //防右键
document.onmouseup =function() {document.selection.empty();}
document.onselect =function() {document.selection.empty();}
document.oncopy =function() {document.selection.empty();}
document.onmousedown =function() {if (event.button!==1){alert('禁止操作');}}
document.onkeydown =function() {alert("禁止操作");event.keyCode=0;event.returnValue=false;}
// 屏蔽PrintScreen
function testclip(){
try {
if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL")) //检测系统内存
{
null; //不为图像则保留内存
}
}
catch(e){
clipboardData.setData("Text","")//清空内存
}
setTimeout("testclip()",500)
}
testclip();//不停清空剪贴板
// 禁止打印
@media print{
body{display:none}
}
// 禁止保存
<noscript>
<iframe src="*.htm"></iframe>
</noscript>
// 禁用右键
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
禁用
window.ClearEvent=function(){event.cancelBubble=false;
var sSrcTagName=event.srcElement.tagName.toLowerCase();
return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");}
window.ClearKey=function(){event.cancelBubble=false;var iKeyCode=event.keyCode;return !(iKeyCode==78 && event.ctrlKey);}
with (window.document){oncontextmenu=onselectstart=ondragstart=window.ClearEvent;onkeydown=window.ClearKey;}
相关文章推荐
- 一行代码完成HibernateTemplate各种数据库操作
- C#各种文件操作的代码与注释
- C#各种文件操作的代码与注释
- 最简单的代码实现禁止鼠标右键及选中网页中的文字,支持Firefox,亲测可用
- Javascript的各种节点操作实例演示代码
- C#各种文件操作的代码与注释
- Mysql数据库的备份和恢复(史上最简单,只需鼠标点击操作,不需要写代码)
- js操作iframe兼容各种主流浏览器示例代码
- 禁止刷新网页、防止刷新网页、禁止后退等操作的代码
- html制作简单框架网页二 实现自己的影音驿站 操作步骤及源文件下载 (可播放mp4、avi、mpg、asx、swf各种文件的视频播放代码)
- 禁止鼠标右键查看网页源代码
- 禁止鼠标左右键代码/禁止网页选中/禁止另存为/防复制代码
- 教你破解网页上各种限制(禁止鼠标右击复制等等)一步搞定!
- HTML网页禁止鼠标操作脚本
- win7系统长时间无操作进入睡眠模式后禁止鼠标和键盘唤醒
- 网页禁止鼠标功能代码之禁止鼠标选中
- Control Study -> 键盘模拟鼠标(实现用键盘操作鼠标光标)(示例代码下载)
- 禁止鼠标左右键代码/禁止网页选中/禁止另存为/防复制代码
- JavaScript控制文本框输入数字并限制其位数和禁止鼠标点击操作
- 队列的基本操作概念及各种实现方式的代码