Question
Luxoft
IN
Last activity: 18 Jul 2018 10:52 EDT
Disabling Right Click across the application
There is a requirement for us to disable mouse right click across the application. Is there any centralized place to make this change?
***Edited by Moderator Marissa to update platform capability tags***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
Hi,
I have tried the below code in IE and it seems to be working.
<script>
function clickIE() {
if (document.all) {
return false;
}
}
function clickNS(e) {
if (document.layers || (document.getElementById && !document.all)) {
if (e.which == 2 || e.which == 3) {
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clickNS;
}
else {
document.onmouseup = clickNS;
document.oncontextmenu = clickIE;
}
document.oncontextmenu = new Function("return false")
</script>
Hope it helps.
Regards,
Rachit
Pegasystems Inc.
IN
Hi
In the portal harness you can use the below code .
Hi
In the portal harness you can use the below code .
document.addEventListener('contextmenu', event => event.preventDefault());
Luxoft
IN
Hi,
This code worked well in Chrome. But it is still an issue in IE. I can still right click in IE and it opens the context menu. Can we restrict the right click across the browsers?
Accepted Solution
Pegasystems Inc.
US
Hi,
I have tried the below code in IE and it seems to be working.
<script>
function clickIE() {
if (document.all) {
return false;
}
}
function clickNS(e) {
if (document.layers || (document.getElementById && !document.all)) {
if (e.which == 2 || e.which == 3) {
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clickNS;
}
else {
document.onmouseup = clickNS;
document.oncontextmenu = clickIE;
}
document.oncontextmenu = new Function("return false")
</script>
Hope it helps.
Regards,
Rachit
-
S MANOJ KUMAR REDDY
Luxoft
IN
Hi Rachit,
I tried but it is not working for me. I just pasted your code to my userworkform html fragment. That is what expected rite? still i can see right click is enabled. I logout and opened the new browser and relogin..still the issue exists. Can please help
Luxoft
IN
Hi Rachit,
Sorry for the confusion. Ur code is working for IE and chrome as of now. Actually i had below code in my html fragment:
document.addEventListener('contextmenu', event => event.preventDefault());
I removed it altogether and added your code. Then it started working.
Thank you so much for all your help.
Adaps
IN
I also got the same requirement it got worked with this code