You are here:   Home
Register   |  Login

Programmer Newsletter

Minimize

Master Programmer

Minimize

Find articles on computer software, programming, ASP.net, Sql server, databases, C#, websites, Internet, Windows, Outlook macros.

Programming Articles

Minimize
04

Here is some useful code to protect the content of your website from the average viewer who may casually try to grab it.

Of course, this will not prevent a determined person.

You can cut and paste all as is into your web page or just the parts you want to disable.

<script type="text/javascript">
//-----------------------------------------------------
// Disable select
document.onselectstart=new Function('return false');
function ffalse(e) {return false;}
function ftrue() { return true; }
document.onmousedown = ffalse;
document.onclick = ftrue;
//-----------------------------------------------------
// Disable right click
var message="You may not right click on this page.";
function noclick(e) {
  if (document.all) {
      if (event.button == 2) { alert(message); return false; } }
  if (document.layers) {
        if (e.which == 3) { alert(message); return false; } }
  }
if (document.layers) { document.captureEvents(Event.MOUSEDOWN); }
// Override what was sent under disable select above
document.onmousedown=noclick;
//-----------------------------------------------------
</script>
<style type="text/css">
/* disable print */
@media print {body {display:none;}}
</style>

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Name (required)

Email (required)

Website

Programmer Newsletter

Minimize

Subscribe to the Internet Handholding newsletter



Reccomend Programmer.bz

Minimize

Share/Bookmark Bookmark and Share