Just needed to add the argument false to the addeventlistener to stop bubbling.
Code:
if(document.addEventListener)
document.addEventListener('contextmenu', function(e) { e.stopPropagation(); }, false);
else if(document.attachEvent)
document.attachEvent('oncontextmenu', function() { event.cancelBubble = true; });
I've sorted the removeEventListener by creating my own function to be called and removing that.
Code:
function disableContextMenu(e)
{
if(!e)
{
event.cancelBubble = true;
}
else
{
if(e.stopPropagation)
{
e.stopPropagation();
}
else
{
return false; //redundant as not called
}
}
}
Bookmarks