i would like to disable a user from right mouse clicking on an embedded youtube video.
How to I do this ?
i would like to disable a user from right mouse clicking on an embedded youtube video.
How to I do this ?
We can set the oncontextmenu="return false" in the tags of the HTML page where you have embedded youtube video
so HTML part will probably look like
<{tagname} oncontextmenu="return false">
...
</{tagname}>
In this way we add a JavaScript method, in this we check if click is right click or left click if it is right click then a message is displayed like "Right click disabled".
Set an id where you have added code for embedded youtube video. Add this Script in the HTML Document for that id.
<script language="javascript">
document.getElementByID({idname}).onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
</script>
Note: In this solution if you click the right click it displays the message:
“Right click disabled”
If we want to remove the message box then this solution do not work.
*Replace {...} with appropriate names.
Reference: Click here