0

I'm using Konqueror 4.14.25 with KHTML engine and cannot disable the right click (the context menu). I've tried

document.addEventListener('contextmenu', function(event) { event.preventDefault() });

but it seems that the contextmenu event does not exist. Using webkit engine i am able to disable the right click! Due to the project tasks I am forced to use Konqueror browser with KHTML engine. Any idea how can I disable the right click?

lazerbrain
  • 171
  • 1
  • 4
  • 17
  • You can try to use capture mode, add the third argument (`true`) to the parameters of `addEventListener`. – Teemu Oct 03 '22 at 07:16
  • I already tried with third arg but won't work. – lazerbrain Oct 03 '22 at 10:20
  • Did you also call `event.stopPropagation`? If the event really doesn't fire at all, you could try to use a click event, check `event.which` and if it's right button (check the correct value, it's browser dependent), prevent the default action and stop propagation. – Teemu Oct 03 '22 at 10:24

1 Answers1

0

After many unsuccessful combinations and tries I finally found one that should work:

        document.oncontextmenu = function() {
           return false;
        }

Also

<body oncontextmenu="return false;">

won't works. The reason is unknown. khtml does not recognize it.

lazerbrain
  • 171
  • 1
  • 4
  • 17