TIL oncontextmenu feature for right-clicking
POSTED ON:
TAGS: javascript events
oncontextmenu #
The oncontextmenu property lets us assign an event handler function to it to handle the contextmenu event. The event is triggered when the right mouse button is clicked on the window. The browser context menu will activate unless the default behavior is prevented.
For example, we can disable right click by writing:
document.oncontextmenu = (event) => {
event.preventDefault();
}
REFERENCE:
MDN
JavaScript Events Handlers — oncontextmenu and oncuechange
Related TILs
Tagged: javascript