如何解除绑定特定页面上的脚本

How to Unbind the Script on specific page

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

JavaScript 没有右键单击和复制命名: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。

我尝试过的: $(文档).ready(函数(){

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

提前致谢

我没看懂你写的完整逻辑。只需尝试将方法 mischandler 覆盖为

function mischandler() { return 1 }

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