欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

js中的屏蔽的使用示例

时间:2021-04-08 10:37:48|栏目:JavaScript代码|点击:
js屏蔽效果
复制代码 代码如下:

/** 屏蔽F1帮助 */
window.onhelp = function(){return false;}
/**
*屏蔽 F5、Ctrl+N、Shift+F10、Alt+F4
*如果想要屏蔽其他键,则找到对应的 keyCode 再依照此方法即可
*/
document.onkeydown = function(event){
event = window.event || event;
if(event.keyCode==116 || (event.ctrlKey && event.keyCode==78) || (event.shiftKey && event.keyCode==121) || (event.altKey && event.keyCode==115)){
event.keyCode =0;
event.returnvalue = false;
}
}
/** 屏蔽鼠标右键 */
document.oncontextmenu = function(){return false;}
//或者
document.onmousedown = function(event){
event = window.event || event;
if(document.all && event.button == 2) {
event.returnvalue=false;
}
}
/**
* 屏蔽“后退”功能(<a href="javascript:replaceLocation('http://www.google.com')" mce_href="javascript:replaceLocation('http://www.google.com')">Google</a>)
* @param url 页面要转向的URL
*/
function replaceLocation(url){
document.location.replace(url);
}
/** 屏蔽选中网页内容 */
document.onselectstart=function(){return false;}
/** 屏蔽复制网页内容 */
document.body.oncopy = function(){return false;}
/** 屏蔽剪切网页内容 */
document.body.oncut = function(){return false;}
/** 屏蔽向网页粘贴内容 */
document.body.onpaste = function(){return false;}
/** 屏蔽拷屏(不停的清空剪贴板) */
window.setInterval('window.clipboardData("Text", "")', 100);
/**
* 屏蔽查看源文件( <body onload=clear()> )
*/
function clear() {
var source=document.body.firstChild.data;
document.open();
document.close();
document.body.innerHTML = source;
}
/**
* 屏蔽js报错
*/
function KillError()
{
  return true;
}
window.onerror=KillError;

上一篇:JS分页效果示例

栏    目:JavaScript代码

下一篇:iframe 上下滚动条如何默认在下方实现原理

本文标题:js中的屏蔽的使用示例

本文地址:http://www.codeinn.net/misctech/96841.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有