Protecting Web Page Content using Javascript

Protecting Web Page Content using Javascript

We can protect our web page content using JavaScript. So that users cannot copy web page contents.

An alert box will appear displaying your copyright information when the right mouse button is clicked.
Copy and Paste the following code into the BODY of your web page.

<SCRIPT language=”JavaScript”>
var message=”Web page contents protected. You cannot view this Page Source.”;
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
</SCRIPT>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.