0

Opera drives me crazy. Dealing with select(ion) is really challenge. I am unable to disable selection with Opera. Selection by mouse or Ctrl+A is still on. Is Opera really so bad, or is there some solution or workaround available?


My CSS:

::selection {
  background: transparent;
} 

::-moz-selection {
  background: transparent;
}

* {
  user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;            // for future? compatibility
  -webkit-user-select: none;
}

My JavaScript:

var elements = document.getElementsByTagName('*');
for (var i = 0; i < elements.length; i++) {
  elements[i].setAttribute('unselectable', 'on');
}

Nothing helps. Please advice.

Example: (if you have Opera available) go to this fiddle, click to "Result" section and press Ctrl+A.

Ωmega
  • 42,614
  • 34
  • 134
  • 203
  • Check out to see if the solution mentioned at http://stackoverflow.com/questions/6299984/disable-text-selection-except-input or http://stackoverflow.com/a/4656495 helps? –  Jul 14 '12 at 15:30
  • @CodeCanvas - thanks, but not... My question is about selection generally, not text only. – Ωmega Jul 14 '12 at 15:43
  • 1
    Reported as bug https://bugs.opera.com/browse/CORE-4736. – Erik Dahlström Jul 16 '12 at 11:48

2 Answers2

0

Reading https://developer.mozilla.org/en/CSS/-moz-user-select user-select is not available on opera. The same applies to internet explorer versions 9 and below.

http://help.dottoro.com/lhwdpnva.php describes how unselectable only works in internet explorer and opera but only for selection starting within the element. Start before or I guess Ctrl+A and you can still select it. According to the article, the same applies to internet explorer.

I haven't been able to try it out however.

jussinen
  • 688
  • 5
  • 16
0

Please try with this script:

<script type="text/javascript">
    disableSelection(document.body) 
</script>

<script type="text/javascript">
    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(e){if(e && e.target && e.target.tagName){if(/^(input|select)$/i.test(e.target.tagName)){return true;}}return false;}
        target.style.cursor = "default"
    }
</script>

Fiddle: http://jsfiddle.net/8qadwtzo/

joseantgv
  • 1,943
  • 1
  • 26
  • 34