I'm using javascript to disable text selection on my webiste.
The code is:
<script type="text/JavaScript"> function disableselect(e) { return false } function reEnable() { return true } document.onselectstart = new Function ("return false") if (window.sidebar) { document.onmousedown = disableselect document.onclick = reEnable } </script>
Similar script can be found here
On my localhost: All Browsers (Firefox, Chrome, IE and Safari) work great.
On my Live site: All ok EXCEPT Firefox.
My questions are:
Does anyone have a suggestion as to why Firefox behaves differently for the live site and local host. Note: Javascript is enabled.
Maybe my script is too simplistic so I've tried the following with EXACTLY SAME Results
You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.
Use the user-select: none; CSS rule.
Just use this css method:
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
You can find the same answer here: How to disable text selection highlighting using CSS?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With