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>
