JavaScript代码实现禁止右键、禁选择、禁粘贴、禁shift、禁ctrl、禁alt

前端之家收集整理的这篇文章主要介绍了JavaScript代码实现禁止右键、禁选择、禁粘贴、禁shift、禁ctrl、禁alt前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

废话不多说了直接给大家贴代码了。

代码如下:

代码 //www.jb51.cc function key(){ if(event.shiftKey){ window.close();} //禁止Shift if(event.altKey){ window.close();} //禁止Alt if(event.ctrlKey){ window.close();} //禁止Ctrl return false;} document.onkeydown=key; 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.onmouown = norightclick; // for all others //-->

1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键特效

2.

3. onpaste="return false" 不准粘贴

4. oncopy="return false;" oncut="return false;" 防止复制

PS:JS防止后退,刷新,关闭解决办法

New Document

猜你在找的JavaScript相关文章