Blog

Home  /  Coding   /  How To Secure Web-Apps From Developer Tools Of Browsers | AV Coding

How To Secure Web-Apps From Developer Tools Of Browsers | AV Coding

Hey guys welcome to AV Coding

Today we will learn how to secure web apps from the developer tools of web browsers using JavaScript.

The complete code is explained in the video below and the source code is provided below.

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
	<meta content="utf-8" http-equiv="encoding">
</head>
<body>
	<div id='content'>
		<h1>hello world</h1>
		<a href="#" onclick="OpenLink('index.html')">open me</a>
	</div>

	<div id="contentShow" style="display: none;">
		<h1>Close Console</h1>
	</div>

<script type="text/javascript">

	var htmlBackUp = '';
	window.addEventListener("resize", orignal);

	function orignal()
	{
	    if ((window.outerHeight - window.innerHeight) > 100 || (window.outerWidth - window.innerWidth) > 50){
	    	if(document.getElementById('content').innerHTML.replace(/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->)(.|\n))*-->/g,"").trim()){
	    		htmlBackUp = document.getElementById('content').innerHTML;
	    		document.getElementById('content').innerHTML = "";
	    		document.getElementById("contentShow").style.display = "block"; 
	    	}
	    }else{
	    	if(htmlBackUp.replace(/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->)(.|\n))*-->/g,"").trim()){
	    		document.getElementById("contentShow").style.display = "none";
	    		document.getElementById('content').innerHTML = htmlBackUp;
	    	}
	    }
	}
	orignal();
	
	function OpenLink(link){
		window.open(link, 'newwindow', 'width='+window.outerWidth+',height='+window.outerHeight);		
	}

</script>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script type="text/javascript">
	$(document).keydown(function (event) {
		if (event.keyCode == 123) {
			return false;
		}
		else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
			return false;
		}
	});
	$(document).on("contextmenu", function (e) {
		e.preventDefault();
	});
</script>
</body>
</html>

Hope You Liked This Blog. Share, Comment, Subscribe And Press The Bell Icon In The Bottom Right Side For More Code Feeds.