zoukankan      html  css  js  c++  java
  • 一个好玩的 屏蔽别人审查元素F12 右键及其他复制粘贴等

    有的时候自己写的私下的个人小页面 里面有些自己的小秘密 或者别的东西 不想人别人审查元素看见 所以我提供了一段不让别人审查元素的代码(我个人比较喜欢弄有意思的东西  喜欢玩 )

    //屏蔽右键菜单
    document.oncontextmenu = function (event){
    if(window.event){
    event = window.event;
    }try{
    var the = event.srcElement;
    if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
    return false;
    }
    return true;
    }catch (e){
    return false;
    }
    }
    //屏蔽粘贴
    document.onpaste = function (event){
    if(window.event){
    event = window.event;
    }try{
    var the = event.srcElement;
    if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
    return false;
    }
    return true;
    }catch (e){
    return false;
    }
    }
    //屏蔽复制
    document.oncopy = function (event){
    if(window.event){
    event = window.event;
    }try{
    var the = event.srcElement;
    if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
    return false;
    }
    return true;
    }catch (e){
    return false;
    }
    }
    //屏蔽剪切
    document.oncut = function (event){
    if(window.event){
    event = window.event;
    }try{
    var the = event.srcElement;
    if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
    return false;
    }
    return true;
    }catch (e){
    return false;
    }
    }
    //屏蔽选中
    document.onselectstart = function (event){
    if(window.event){
    event = window.event;
    }try{
    var the = event.srcElement;
    if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
    return false;
    }
    return true;
    } catch (e) {
    return false;
    }
    }

    但是上面可以F12审查元素喔  所以下面提供了一段禁用F12的代码 

    document.onkeydown = function(){

    if(window.event && window.event.keyCode == 123) {
    alert("F12被禁用");
    event.keyCode=0;
    event.returnValue=false;
    }
    if(window.event && window.event.keyCode == 13) {
    window.event.keyCode = 505;
    }
    if(window.event && window.event.keyCode == 8) {
    alert(str+" 请使用Del键进行字符的删除操作!");
    window.event.returnValue=false;
    }

    }

    备注:这些只能对于一般人,一般人,一般人(重要的事情说三篇)!!!
  • 相关阅读:
    IOS手机 html5页面 数字变成蓝色链接的原因
    html5预加载图片的写法
    jquery取消绑定的方法
    CSS3幸运大转盘最简单的写法
    深度搜索应用之黑白图像(非递归)
    springday03-go1
    springday02-go4
    spring day02-go3
    springday02-go2
    spring da-y02-go1
  • 原文地址:https://www.cnblogs.com/fightjianxian/p/8965008.html
Copyright © 2011-2022 走看看