admin管理员组文章数量:1386311
how to disable right click, f12(debug) and ctrl+s in asp application using javascript or jquery.. Have to black ctrl+s --> Do not allow to save the page Have to black f12 and right click--> Do not allow to inspect/debug/view source of the page
how to disable right click, f12(debug) and ctrl+s in asp application using javascript or jquery.. Have to black ctrl+s --> Do not allow to save the page Have to black f12 and right click--> Do not allow to inspect/debug/view source of the page
Share Improve this question edited Mar 26, 2014 at 12:50 Naveenkumar asked Mar 26, 2014 at 12:22 NaveenkumarNaveenkumar 4736 silver badges20 bronze badges 8- I hope this is not for security reason than you are looking for preventing that behaviour – A. Wolff Commented Mar 26, 2014 at 12:24
- 2 Just wondering, which bank website it is?... ;) – A. Wolff Commented Mar 26, 2014 at 12:29
- 3 @naveenkumar That will not help improve your "security" at all. – tckmn Commented Mar 26, 2014 at 12:32
- 1 @naveenkumar "for security purpose" But that's for sure a no go... Sensible datas are set and get server side, it must not be provided client side. You have then to redesign all your logic/system – A. Wolff Commented Mar 26, 2014 at 12:32
- 1 @A.Wolff yes, your second ment is great! Dear naveenkumar please tell us, which bank are you working for? I won't put my money there but I can always wander around :) – ElmoVanKielmo Commented Mar 26, 2014 at 12:37
4 Answers
Reset to default 8"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.
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 ments 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.
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.
<script type="text/javascript">
if (document.layers) {
//Capture the MouseDown event.
document.captureEvents(Event.MOUSEDOWN);
//Disable the OnMouseDown event handler.
document.onmousedown = function () {
return false;
};
}
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.
return false;
}
}
};
}
//Disable the Context Menu event.
document.oncontextmenu = function () {
return false;
};
document.onkeydown = ShowKeyCode;
function ShowKeyCode(evt) {
if (evt.keyCode == '123')
return false;
//For F12 Button
}
</script>
本文标签:
版权声明:本文标题:how to disable right click, f12(debug) and ctrl+s in asp.net application using javascript or jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744538050a2611435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论