This is very common that we get requirement or scope to disable some specific div(s) or section because of security reasons.

Simple solution: Add

oncontextmenu="return false;"

Example

<div oncontextmenu="return false;">Disabled right click contents</div>

Another Solution, add below javascript.

 document.getElementById("divId").addEventListener("contextmenu ", function(){
       console.log("Right Click");
       return false;
    });

Regards

By Rijwan Ansari

MVP, CSM, CSPO, MCP, MCTS. Sr. Software Developer. Expertise in ASP.NET MVC, Angular, AngularJs, .Net Core, C#.NET, Azure, Cognitive Services, Machine Learning, SharePoint, Azure Services, and tools, Requirement Analysis, Team Management, Pre-Sales and more. Ability to work independently and Team, handle pressure and meet commitment. Excellence Communication and adjust in any environment

Leave a Reply

Your email address will not be published. Required fields are marked *