You can disable the browser context menu for an element in your DOM with the following JavaScript recipe:
function disableContextMenu(element)
{
element.oncontextmenu = function()
{ return false; }
}
For example, to disable the context menu over a photo on your page, you could use:
disableContextMenu(document.getElementById("photo"));
Browsers like Firefox do not always allow web pages to disable the context menu (this option is a setting in Firefox), so this recipe will not work 100% of the time in all browsers.
No comments:
Post a Comment