How to Disable Right Click on Images?

Pendem RajuHow To0 Comments

Being a blogger or content creator we add images to our posts. Images express more than words. But when someone visits your website or blog they simply right click on the image to save and use it in their content. There are lot of functions of right-click like page reloading, open link in new tab etc. So disabling right click on image is enough. To disable right click on images follow the instructions.

How to Disable Right Click on Images?

1. To disable right click on all images – Go to your blogger dashboard, click on Template then click on Edit HTML and click tho proceed and Expand widget templates and copy the following code immediately after </head>

 <script type=”text/javascript”>
//<![CDATA[
function nocontext(e) {
var clickedTag = (e==null) ? event.srcElement.tagName : e.target.tagName;
if (clickedTag == “IMG”) {
alert(alertMsg);
return false;
}
}
var alertMsg = “Image context menu is disabled”;
document.oncontextmenu = nocontext;
//]]>
</script>

2. To disable right click on single image –

disable right cllick on images

Normal image tag will be like this
<img  border="0" src="url of image" />

To disable right click add this code in image tag.
oncontextmenu=’alert(“Image context menu is disabled”);return false;’

Final tag will be like this
<img oncontextmenu=’alert(“Image context menu is disabled”);return false;’  border="0" src="url of image" />

You can change the highlighted text according to your wish.

Leave a Reply

Your email address will not be published. Required fields are marked *