【JavaScript】JavaScript禁止右鍵菜單和F12打開控制台看代碼


<script type="text/javascript">
//禁止鼠標右鍵菜單和F12打開控制台看源碼
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
alert("歡迎光臨寒舍,有什么需要幫忙的話,請與站長聯系!謝謝您的合作!!!");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
// <--123——112是F1-F12的代碼數-->
</script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM