Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent context menu in Edge when text is selected

In its recent version, Edge shows a context menu when selecting text. Is there any way to prevent this behaviour with JavaScript? I tried window.oncontextmenu = e => {e.preventDefault();}; but this wasn't successful.enter image description here

like image 572
QwertyM Avatar asked Feb 01 '26 16:02

QwertyM


2 Answers

If you don't need to use this feature in Edge, you can disable this menu via specific setting in Edge.

Just follow these steps:

  1. Naviagte to edge://settings/appearance in Edge.
  2. Scroll down the page to the Context menus section.
  3. Disable the option Show mini menu when selecting text.

Something like this:

enter image description here

In addition, you can also disable this feature on specific sites, depending on your needs.

like image 182
Xudong Peng Avatar answered Feb 04 '26 06:02

Xudong Peng


window.onmouseup = event => event.preventDefault();
like image 40
DepictDev Avatar answered Feb 04 '26 05:02

DepictDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!