如何在特定页面上取消绑定脚本

时间:2016-12-22 11:03:03

标签: javascript c# jquery asp.net-mvc copy-paste

我认为我在MVC中有一个Web应用程序,由于安全原因我们没有启用右键单击,我想启用右键单击单击页面下面是代码

JavaScript for no rightclick& copy名称:ContentCopy.js

function mischandler()

    { return !1 }
    function mousehandler(n) {


        var e = isns ? n : event, t = isns ? e.which : e.button; return 2 == t || 3 == t ? !1 : void 0
    } var isctrl = !1; document.onkeyup = function (n) { return 17 == n.which ? (isctrl = !1, !1) : void 0 },
    document.onkeydown = function (n)
    { return 17 == n.which ? (isctrl = !0, !1) : 67 == n.which && 1 == isctrl ? !1 : void 0 },
    document.onkeypress = function (n) { return 17 == n.which ? (isctrl = !0, !1) : 67 == n.which && 1 == isctrl ? !1 : void 0 };
    var isns = "netscape" == navigator.appname ? 1 : 0;
    "netscape" == navigator.appname && document.captureevents(event.mousedown || event.mouseup),
    document.oncontextmenu = mischandler, document.onmousedown = mousehandler, document.onmouseup = mousehandler;

我在布局中调用了这个JS。

我曾尝试过:     $(document).ready(function(){

    $(document).undelegate("~/Content/js/ContentCopy.js");
    $(document).undelegate("mischandler");
    $('#BoxId').unbind("mischandler");
    $(document).removeEventListener("mischandler", mischandler);
});

先谢谢

1 个答案:

答案 0 :(得分:1)

我没有得到你所写的完整逻辑。只是尝试覆盖方法mischandler

function mischandler() { return 1 }

并检查功能。 https://jsfiddle.net/towkwa6q/