0

Just want to know how to disable right click on dashboard(admin area) side of the wordpress.already used following code for frontend(user area).

body {
  -webkit-user-select: none;
     -moz-user-select: -moz-none;
      -ms-user-select: none;
          user-select: none;
}   
0

Use the selector .wp-admin to make sure you are selecting only the wordpress admin area.

html body.wp-admin {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

The code above will prevent the user from selecting/highlighting the page content.

If you really want to disable right click, just use a simple JS code like:

<script>
document.oncontextmenu = new Function("alert('Right click is blocked.'); return false");
</script>

References:

https://css-tricks.com/almanac/properties/u/user-select/

  • thanks for the answer @filipecsweb.it worked .Also is it possible to prevent ctrl+u and ctrl+f using the same kind of code. – Radun De Silva Feb 27 at 18:55
  • 1
    I'm afraid not with one line of code. Refer to stackoverflow.com/questions/6597224/… and check if you can enlighten yourself. – filipecsweb Feb 27 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.