Skip to content Skip to sidebar Skip to footer

How To Disable Right Click, F12(debug) And Ctrl+s In Asp.net Application Using Javascript Or Jquery

how to disable right click, f12(debug) and ctrl+s in asp.net application using javascript or jquery.. Have to black ctrl+s --> Do not allow to save the page Have to black f12

Solution 1:

"Do not allow to save the page" - This is impossible, as this would require not delivering the page to the user in the first place.

"Do not allow to inspect/debug/view source of the page" - This is also impossible. In Chrome you can prepend view-source: to the URL, and you can get to developer tools with Menu -> Tools -> Developer Tools. In any case, the browser has to have access to the source code to actually display the page.

What you are trying to do is impossible. There is also absolutely no reason to. (It's also highly annoying to legitimate users who actually want to right click!) If you're trying to do this for "security," this is most definitely not your biggest problem. If there's any insecure information delivered to client side, you have to redesign your entire system immediately.

Solution 2:

Forget about it! I can write my own web browser which doesn't have right click, F12 and CTRL+S and I can still see the HTML and Javascript source. I can even do this with telnet. If your manager gave you such requirements I would tell him to go back to primary school. I know you can't tell him this. But really: You can't rely on the fact that some user agents will respect your tricks. This won't improve security - this will give you nothing.

Just some background information: Some time ago I've written a script for Selenium WebDriver to control Firefox. I was able to grab any data, read all the scripts and moreover inject my own JS to any website. You should listen to the comments and answers and provide security on the server side because everything your server sends as a response can be read, saved and processed one way or another.

Solution 3:

There are some legitimate reasons for this functionality. We are doing web-based testing in a school district and we have to provide a reasonable assurance that students will not be able to find the source file of a test and download it or email it to themselves during the test. For that reason we have to disable right click and do everything we can to ensure that F12 and Ctrl U does not work. School districts with minimal budgets have no choice but to rely on these tricks to help get more done with less.

Solution 4:

<scripttype="text/javascript">if (document.layers) {
//Capture the MouseDown event.document.captureEvents(Event.MOUSEDOWN);

                    //Disable the OnMouseDown event handler.document.onmousedown = function () {
                        returnfalse;
                    };
                }
                else {
                    //Disable the OnMouseUp event handler.document.onmouseup = function (e) {
                        if (e != null && e.type == "mouseup") {
                            //Check the Mouse Button which is clicked.if (e.which == 2 || e.which == 3) {
                                //If the Button is middle or right then disable.returnfalse;
                            }
                        }
                    };
                }

                //Disable the Context Menu event.document.oncontextmenu = function () {
                    returnfalse;
                };
                document.onkeydown = ShowKeyCode;
                functionShowKeyCode(evt) {
                    if (evt.keyCode == '123')
                        returnfalse;
                     //For F12 Button 
                }
</script>

Post a Comment for "How To Disable Right Click, F12(debug) And Ctrl+s In Asp.net Application Using Javascript Or Jquery"