最新文章:
- 腾讯九年,他为何选择辞职
- 为什么CTO、技术总监、架构师都不写代码,还这么牛逼
- 有道云笔记MAC客户端无法同步解决办法
- Chrome88稳定版已发布,不再支持 Flash
- node.js版本管理工具n的使用
js方法禁止查看源文件、防止复制、禁止右键、总结
发布时间:2017年09月10日 评论数:抢沙发阅读数: 2504
1、锁定右键
将网页中的换为如下代码即可:
<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">
2、拒绝另存
<noscript><iframe src="/*>";</iframe></noscript>
3、不准粘贴
onpaste="return false"
4、防止复制
oncopy="return false;" oncut="return false;"
5、关闭输入法
6、JS 屏蔽鼠标右键
7、禁用f12调试键(但是不支持火狐)
<input style="ime-mode:disabled">
/** 屏蔽鼠标右键 */
document.oncontextmenu = function(){return false;}
//或者
document.onmousedown = function(event){
event = window.event || event;
if(document.all && event.button == 2) {
event.returnvalue=false;
}
}
document.onkeydown=function (e){
var currKey=0,evt=e||window.event;
currKey=evt.keyCode||evt.which||evt.charCode;
if (currKey == 123) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}
本文地址:
http://arbays.com/post-38.html
 本文已被百度收录!
版权声明:若无注明,本文皆为“富录-前端开发|web技术博客”原创,转载请保留文章出处。