Reputation: 870
I am trying to prevent the standard right click menu from popping up on some information so i can display my own custom right click menu.
Right now I am getting both with the standard one appearing over the custom.
Here's my html:
<span onmouseup=\"OnRowMouseUp('Filename');\">Filename</span>
Here's my JavaScript:
var OnRowMouseUp = function (selectedField) {
e = window.event;
e.preventDefault();
console.log(e);
//this.ShowContextMenu(selectedField, e.clientX, e.clientY);
}
e is definitely a mouse event as I can view it in console. A lot of the other SO answers say that I should be using preventDefault()
but it dosen't seem to be working in this circumstance. Any ideas?
Upvotes: 0
Views: 58
Reputation: 870
What you're looking for is the contextmenu
event.
<span oncontextmenu="OnRowMouseUp(Filename);">Filename</span>
Or
element.addEventListener('contextmenu', () => {
});
After this, preventDefault should work as expected.
Upvotes: 2