Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While I agree in principle with the other posters that trying to do this may annoy the user, sometimes a manager or customer demands that this be done, and so an answer needs to be supplied.</p> <p>Check out <a href="http://www.dynamicdrive.com/dynamicindex9/" rel="nofollow noreferrer">this page</a> on www.dynamicdrive.com that will supply you with a few JavaScripts towards this end. Specifically see "Disable Text Select Script" and "No right click script".</p> <p>Disable Text Select Script:</p> <pre><code>/*********************************************** * Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ function disableSelection(target){ if (typeof target.onselectstart!="undefined") //IE route target.onselectstart=function(){return false} else if (typeof target.style.MozUserSelect!="undefined") //Firefox route target.style.MozUserSelect="none" else //All other route (ie: Opera) target.onmousedown=function(){return false} target.style.cursor = "default" } //Sample usages //disableSelection(document.body) //Disable text selection on entire body //disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv" </code></pre> <p>No right click script:</p> <pre><code>//Disable right mouse click Script //By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive //For full source code, visit http://www.dynamicdrive.com var message = "Function Disabled!"; /////////////////////////////////// function clickIE4() { if (event.button == 2) { alert(message); return false; } } function clickNS4(e) { if (document.layers || document.getElementById &amp;&amp; !document.all) { if (e.which == 2 || e.which == 3) { alert(message); return false; } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = clickNS4; } else if (document.all &amp;&amp; !document.getElementById) { document.onmousedown = clickIE4; } document.oncontextmenu = new Function("alert(message);return false") </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload