Disable Right Clicking on Webpage, Images and Photos with JavaScript
Add the following code to the head section of your html document to disable right clicking on your webpage. This way, users wll not be able to right click and save pictures or photographs from your website.
Note: However, users can use other ways to save the photos from your website such as looking at the source code and browsing to the location of the picture and then save it.
<script language=JavaScript>
<!-- //Hide from old Browsers
var message="No Right Clicks Please";
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;
// END HIDE-->
</script>
Related Articles
- Validate a Check Box Using JavaScript
- Automatic Redirect using Javascript
- Multi Level Drop Down Category & Subcategory Hierarcheal Selection using JavaScript
- Flash and JavaScript Conflict: Javascript Menu goes behind the flash file
- Display Current Date Automatically on your Website using JavaScript
- How to Create a Reload Button which will Reload the Webpage upon Clicking using JavaScript
- Automatically Redirect from one Webpage to Another Webpage using JavaScript
- How to Display a Webpage in the PopUp Window after Clicking from a Link using JavaScript
