• 防止代码被扒


    ```
    //若是你不想别人扒掉你的模板,可以把这段js代码加到你网页上,即可屏蔽鼠标右键菜单、复制粘贴、选中等


    //屏蔽右键菜单
    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;

    }

    }
    ```

  • 相关阅读:
    JVM基础系列第1讲:Java 语言的前世今生
    JVM基础系列开篇:为什么要学虚拟机?
    2018 精选文章集合
    如何唯一确定一个 Java 类?
    Java 中的 try catch 影响性能吗?
    不读大学也能成功,七个读大学的备用选择
    【中间件安全】IIS7.0 安全加固规范
    【中间件安全】Apache 安全加固规范
    Excel 保护工作表
    【应用安全】S-SDLC安全开发生命周期
  • 原文地址:https://www.cnblogs.com/TigerZhang-home/p/7743478.html
Copyright © 2020-2023  润新知