Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • Works great! This should be the new accepted answer
    – towe
    Commented Feb 4, 2022 at 8:28
  • I came across a webpage where appending a style element didn't work so I changed it to this: var body = document.getElementsByTagName("body")[0]; body.setAttribute("style", 'user-select: auto !important;-webkit-user-select: auto !important;');
    – t3chb0t
    Commented Jul 11, 2022 at 20:16
  • nice, need more one code with context after onselectstart, we need context for copy a text document.body.oncontextmenu=function(){return true};
    – KingRider
    Commented Dec 27, 2022 at 17:10
  • Best solution for the challenged and lazy @rses ^_^
    – Whoever
    Commented Jan 1, 2023 at 13:43
  • Works perfect. Thank for saving time and effort. Commented May 15, 2023 at 8:48