Method of forbidding to view web page source code

There are always novices asking,How to prohibit others to view their own web page source code?The answer is No,For the experienced, all methods are futile。

Method of forbidding to view web page source code

The common method is to add a similar pageJScode,Shielding keyboard and right mouse button。

document.onkeydown = function() {
	var e = window.event || arguments[0];
	if (e.keyCode == 123) {
		alert('prohibitF12');
		return false;
	} else if ((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
		alert('prohibitCtrl+Shift+I');
		return false;
	} else if ((e.ctrlKey) && (e.keyCode == 85)) {
		alert('prohibitCtrl+u');
		return false;
	} else if ((e.ctrlKey) && (e.keyCode == 83)) {
		alert('prohibitCtrl+s');
		return false;
	}
}
// Screen the right mouse button
document.oncontextmenu = function() {
	alert('prohibit右键');
	return false;
}

上述code用下面的包裹起来之后,Do not display prompt information:

window.onload = function() {
// code
}

Another paragraphJScode,It can prevent the normal use of browser development tools

<script type="text/javascript">
((function() {
	var callbacks = [],
	timeLimit = 50,
	open = false;
	setInterval(loop, 1);
	return {
		addListener: function(fn) {
			callbacks.push(fn);
		},
		cancleListenr: function(fn) {
			callbacks = callbacks.filter(function(v) {
				return v !== fn;
			});
		}
	}
	function loop() {
		var startTime = new Date();
		debugger;
		if (new Date() - startTime > timeLimit) {
			if (!open) {
				callbacks.forEach(function(fn) {
					fn.call(null);
				});
			}
			open = true;
			window.stop();
			alert('prohibit查看');
			window.location.reload();
		} else {
			open = false;
		}
	}
})())

.addListener(function() {
	window.location.reload();
});
</script>

 

上述方法只要浏览器prohibitJSAll scripts will be invalid,Although there are still people trying to study this,But foxes andchrome众多一键prohibitJSExpansion makes these efforts meaningless。

There seems to be a more hidden way,When the browser development tool window is opened, the page size changes,adoptJSJudge the change of browser window,在开发工具中看不到源code,But after knowing the principle,It’s also a cover up…

 

Related Article
Gitee is unable to push the updated version. The error “updates were rejected” is prompted

There are some collaborative office development times,Or useGITVersion control is better,And some open source software can be downloaded and released Read more

Making energy flow effect with CSS animation and SVG

The final effect is as follows: the animation is divided into two steps making the running track Creating the DOM Read more

WordPress 3D rotating tag cloud

This 3D tag cloud is not the flash version of WP cumulus n years ago. This 3D rotating tag cloud Read more

Using wampserver tool to build local PHP + MySQL environment

No matter whether we use domestic space or foreign hosts, we prefer to go online after local debugging before setting Read more

Leave a Reply

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

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image