Stopping right clicks by visitors
Sponsored Links
If you want to protect and secure content on your web page, you need to disable right clicking by visitors. When visitors right-click on a web page, they can copy images by selecting the appropriate option from the displayed menu. Here I'll show you how to prevent right clicks on a web page and thus (?... read note below) protecting and securing the images and content on your web page. We'll employ JavaScript and write a function that displays an "alert" box when the visitor right-clicks on the page. Try right-clicking on this page.
Put the following code inside the HEAD of your HTML document. This will display an alert when a visitor right-clicks on the page. You can customize the text displayed in the alert box by changing the value of msg variable.
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function click(e)
{
var msg = "No right click is allowed";
if (document.all)
{
if (event.button == 2)
{
alert(msg);
return false;
}
}
if (document.layers)
{
if (e.which == 3)
{
alert(msg);
return false;
}
}
}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
//-->
</script>
Note: This method is not foolproof. A visitor will still be able to save an image if he/she keeps the left mouse pressed and then right-clicks on the page. Also, this method will not work on older browsers or browsers in which JavaScript has been disabled.
Page contents: Stopping right clicks by visitor to prevent and protect images displayed on a web page.
Comments, questions, feedback... whatever!
Recent Articles
Recent Blog Posts
Popular Articles
- Hotmail Sign In page
- Create a Hotmail account - Instructions
- Create Gmail address
- Download and install Outlook Express
- Get your free Gmail address
- Outlook Express new version
- Create my own email address
- Browers for Windows list
- Get email address
- Color combinations for web sites and pages
- Create Yahoo ID
More web tips & tricks
- Outlook Express Help - tips & tricks (53)
- Windows Live Mail help and tips (36)
- Windows Mail help (25)
- Hotmail help and tips (42)
- Yahoo help & support (45)
- AOL email help (26)
- Gmail help and tips (36)
- Internet tips & tricks (12)
- Web Design tips & tricks (33)
- HTML, Javascript tips tricks (68)
- Web Promotion tips & tricks (8)
- Graphics tips & tricks (20)
