Website Templates Right Click Protection

Adding/Removing Right Click Protection



To Add Right Click Protection
Add the following code to the top of any web page anywhere between the <head> and </head> tags. This can be added to any .html page or the slideshow.htm.

<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<script language="JavaScript">
function noRightClick() {
if (event.button==2) {
alert('You may not right mouse click this page.')
}
}
document.onmousedown=noRightClick
</script>


For older templates with popup gallery images.
To prevent right click in the pop-up windows. Edit the "pop-closeup.js" in Notepad and add these lines just before the <body bgcolor="# etc...>

popwin.document.write('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">')
popwin.document.write('<script language="JavaScript">')
popwin.document.write('function noRightClick() {')
popwin.document.write('if (event.button==2) {')
popwin.document.write('alert(\'You may not right mouse click this page.\')')
popwin.document.write('}')
popwin.document.write('}')
popwin.document.write('document.onmousedown=noRightClick')
popwin.document.write('</script>')


To Remove Right Click Protection
To remove right click protection from a gallery, web page or pop-up, simply remove the above code from your "pop-closeup.js", Or, in most newer models remove the code as shown below from your "slideshow.htm" and your "image-viewer.htm".

<script language="JavaScript" type="text/javascript">
<!-- Begin
var message="You may not right mouse click this page.";
if (navigator.appName == 'Microsoft Internet Explorer'){
function NOclickIE(e) {
if (event.button == 2 || event.button == 3) {
alert(message);
return false;
}
return true;
}
document.onmousedown=NOclickIE;
document.onmouseup=NOclickIE;
window.onmousedown=NOclickIE;
window.onmouseup=NOclickIE;
}
else {
function NOclickNN(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=NOclickNN; }
document.oncontextmenu=new Function("alert(message);return false")
}
// End -->
</script>




Adding More Secure Right Click Protection
The scripts below are for right click protection in most browsers and is a more secure script than is added to most Allwebco templates.
javascript right click protection
HTML code for IE, Firefox, Chrome, Safari, Opera and Netscape
The following script will disable right click in most browsers. Copy and paste this at the top of any web page anywhere between the <head> and </head> tags. This can be added to any .html page like the "slideshow.htm" or "image-viewer.htm".




.js code for IE, Firefox, Chrome, Safari, Opera and Netscape
The following script will disable right click in most browsers. Copy and paste this code into a .js file like your header.js. Generally this can go anywhere in a .js file. For templates with popup window type image viewers, see the pop-closeup.js code in the next section.




OUTDATED CODE IN pop-closeup.js (Older templates)
The following code is only for templates with popup window image or mp3 viewers and should only be added to a "pop-closeup.js". In most cases this should replace existing code. See "code to replace" below.



Code to replace:
If you are adding more secure right click protection in a "pop-closeup.js" you will replace the code below with the code shown above:

popwin.document.write('<script language="JavaScript">')
popwin.document.write('function noRightClick() {')
popwin.document.write('if (event.button==2) {')
popwin.document.write('alert(\''+right_click_text+'\')')
popwin.document.write('}')
popwin.document.write('}')
popwin.document.write('document.onmousedown=noRightClick')
popwin.document.write('</script>')


NOTE: Be sure to make a backup of your "pop-closeup.js" before you start editing.

Allwebco Template Support


Allwebco Templates Adding Right Click Protection


Allwebco Web Templates
Complete websites with built in scripts.
AllwebcoDesign.com
Web Site Templates
Free Javascripts
Free scripts for any website or template.
Allwebco-Templates
Web Template Support
Mobile Web Templates
HTML5 / CSS website designs.
AllwebcoDesign.com
Web Site Templates
Shopping Cart Templates
Professional templates with built-in Paypal.
AllwebcoDesign.com



Website Template Support
Website Template Support