zoukankan      html  css  js  c++  java
  • 页面禁止右击

    var zhonghao={

    //绑定事件

    myAddEvent: function(obj, sEvent, fn){if(obj.attachEvent){obj.attachEvent('on'+sEvent, fn);}else{obj.addEventListener(sEvent, fn, false);}},

    //禁止选择文本

    disableselect:function(e){

    var omitformtags=["input", "textarea", "select"]

    omitformtags=omitformtags.join("|")

    if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)

    return false

    },

    reEnable:function(){

    return true

    },

    //禁用右键

    stop:function(){

    return false;

    }

    }

    zhonghao.myAddEvent(window,"load",function(){

    //禁止选择文本

    if (typeof document.onselectstart!="undefined")

    document.onselectstart=new Function ("return false");

    else{

    document.onmousedown=zhonghao.disableselect ;

    document.onmouseup=zhonghao.reEnable ;

    }

    //禁止右键

    document.oncontextmenu=zhonghao.stop;

    })

    转载请注明出处: 欢迎留言或qq(1090413588)交流
  • 相关阅读:
    复习 层叠样式表
    asp后台练习总结
    序列化
    WindowsForm 增 删 查 改
    WindowsForm 计算器
    UML建模和开发预演
    rabbitmq 使用心得
    设计模式之策略模式
    单一职责原则
    设计模式之工厂模式
  • 原文地址:https://www.cnblogs.com/linyusong/p/5528172.html
Copyright © 2011-2022 走看看