Disabling Window context menu/ mouse right click in javascript

In this javascript tutorial we will learn how to disable the window context menu which comes when user right click over the webpage. Sometimes programmers disable the mouse right click so that window context menu cannot be opened but by pressing using window context menu button in keyboard (normally located at left of Ctrl button) user can still open the window context menu. So let's see how to disable this in javascript

You can disable window context menu by using oncontextmenu event handler in the body tag of your web page like given below

<body oncontextmenu="return false;">

So this is the way to disable mouse right click as well as disable the window context menu in javascript.

0 comments: