简体   繁体   English

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

[英]How to Unbind the Script on specific page

I Guys i have a web application in MVC where we had not enabled Right click due to security reason and i want to Enable that Right click on singe page Below is the code 伙计们,我在MVC中有一个Web应用程序,出于安全原因,我们尚未启用右键单击功能,我想在单页上启用该右键单击功能,以下是代码

JavaScript for no rightclick & copy Named : ContentCopy.js 没有右键单击和复制的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;

I had Called this JS in Layout. 我曾在Layout中称之为JS。

What i had tried : $(document).ready(function () { 我试过的是:$(document).ready(function(){

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

Thanks in Advance 提前致谢

I didn't get the complete logic what you've written. 我没有得到您所写的全部逻辑。 Just try overwriting the method mischandler to 只需尝试覆盖错误的方法即可

function mischandler() { return 1 }

and check the functionality. 并检查功能。 https://jsfiddle.net/towkwa6q/ https://jsfiddle.net/towkwa6q/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM