Example: http://www.snopes.com/business/genius/genius.asp
None of the text is highlightable - I've never seen something like this. Tried to look at the source code, but could not find, not did Google provide any answers.
I'm assuming it's a JS trick? The text is in the source code, so it's not an image. Actually nothing is highlightable on the page.
How is this done?
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.
Read the source code of the page you have linked to:
<script type="text/javascript">
<!--
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
-->
</script>
In Chrome, entering document.onselectstart = function() {return false}
into the Javascript console seems to do the trick.
But don't do it, it's infuriating.
This is the script area where they disable the selection:
<script type="text/javascript">
<!--
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
-->
</script>
The document.onmousedown = disableselect is the key line.
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