Select-disabling JS



  • Damn! I've noticed recently that some pages won't allow me to select text anymore. Guess what I found on the source code:

    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
    }

     So it looks like all this Web 2.0 stuff has actually enabled webmasters to "disable" text selecting. How retarded, given that simply disabling JavaScript kills this "security". Seriously, this seems as retarded as those right-click disablers. Oh well, I'll have to implement some filtering to wash out the offending code now...



  • Shouldn't this be in the sidebar?



  •  I've seen this, but this fails to disable the keyboard caret. You can position thecaret with the mouse and then use shift + arrowkeys to select whatever you want. This doesn't even require looking at the page source or disabling javascript to get around...



  • I guess TRWTF is the fact that whoever wrote and/or deployed the script was ignorant of the user-select CSS3 atribute, its vendor-specific offspring and IE's unselectable HTML attribute.

    <div style="user-select: none; -khtml-user-select: none; -moz-user-select: none;" unselectable="on">Can't select me.</div>



  •  Which pages are these?



  • @Ragnax said:

    I guess TRWTF is the fact that whoever wrote and/or deployed the script was ignorant of the user-select CSS3 atribute, its vendor-specific offspring and IE's unselectable HTML attribute.

    <div style="user-select: none; -khtml-user-select: none; -moz-user-select: none;" unselectable="on">Can't select me.</div>

    True, but arguably those are fairly obscure attributes.



  • @morbiuswilters said:

    @Ragnax said:

    I guess TRWTF is the fact that whoever wrote and/or deployed the script was ignorant of the user-select CSS3 atribute, its vendor-specific offspring and IE's unselectable HTML attribute.

    <div style="user-select: none; -khtml-user-select: none; -moz-user-select: none;" unselectable="on">Can't select me.</div>

    True, but arguably those are fairly obscure attributes.

     

    Also, at least Firefox seems to lure the web author in a false sense of security with them (hold your "duh"s just a bit). CTRL+A seems still to work. You don't get visual feedback, but if you do "copy" afterwards, you will have the text in your clipboard.

    Also, of you have unselectable text between two groups of selectable text, you can drag your selection over both groups and it will, again "invisibly", select the text in between as well.

    (Example: <p>[A] <span style="user-select: none; -khtml-user-select: none; -moz-user-select: none;" unselectable="on">Can't select me.</span> [B]</p>)

    I think both are things that even a non-computer-savy user may eventually come up with.

    Maybe Firefox does this on purpose though, who knows... ;)



  • @PSWorx said:

    Also, at least Firefox seems to lure the web author in a false sense of security with them (hold your "duh"s just a bit). CTRL+A seems still to work. You don't get visual feedback, but if you do "copy" afterwards, you will have the text in your clipboard.

    Also, of you have unselectable text between two groups of selectable text, you can drag your selection over both groups and it will, again "invisibly", select the text in between as well.

    (Example: <p>[A] <span style="user-select: none; -khtml-user-select: none; -moz-user-select: none;" unselectable="on">Can't select me.</span> [B]</p>)

    I think both are things that even a non-computer-savy user may eventually come up with.

    Maybe Firefox does this on purpose though, who knows... ;)

    You seem to misunderstand the point of disabling text selection.  It's not to prevent people from copying the page, it's to prevent dragging actions in the GUI from highlighting the text.  So if you have a mail client users can drag-and-drop a message in a folder without the text on the page spazzing out with highlighting. 



  • @morbiuswilters said:

    You seem to misunderstand the point of disabling text selection.  It's not to prevent people from copying the page, it's to prevent dragging actions in the GUI from highlighting the text.  So if you have a mail client users can drag-and-drop a message in a folder without the text on the page spazzing out with highlighting. 

    Hmm, agreed, I did misunderstand that. From that new point of view, Firefox' implementation makes sense. Thanks for clearing that up.



  • @morbiuswilters said:

    You seem to misunderstand the point of disabling text selection.  It's not to prevent people from copying the page, it's to prevent dragging actions in the GUI from highlighting the text.  So if you have a mail client users can drag-and-drop a message in a folder without the text on the page spazzing out with highlighting. 

    Nice, so that's what it's supposed to be for. However the above example comes from snopes.com, and I doubt they've got Web 2.0-ish GUIs there. So it seems more like feature abuse rather than GUI needs. By the way, codinghorror.com also uses something similar. Just try to select text in the "comments" area...


  • @danixdefcon5 said:

    So it seems more like feature abuse rather than GUI needs.

    Sure, that happens.

     

    @danixdefcon5 said:

    By the way, codinghorror.com also uses something similar. Just try to select text in the "comments" area...

    I was shocked to hear Jeff Atwood would do something so stupid, so I went straight to the site to see for myself.  I can select text just fine in the comments area and to be quite honest, I remember copying lines from others replies so I could respond to them in detail.  I don't read CH anymore but I don't recall it ever doing something nutty like disabling text selection.  Perhaps you are remembering it incorrectly? 



  • @morbiuswilters said:

    I was shocked to hear Jeff Atwood would do something so stupid, so I went straight to the site to see for myself.  I can select text just fine in the comments area and to be quite honest, I remember copying lines from others replies so I could respond to them in detail.  I don't read CH anymore but I don't recall it ever doing something nutty like disabling text selection.  Perhaps you are remembering it incorrectly? 

    Yup, ture, no select-killing code there. But check out:

     http://www.codinghorror.com/blog/archives/000128.html

    Go down to the section where he says "I always convert to VB.net" and try to select text. Something weird happens there, its selecting text starting from the BLOCKQUOTE area, down to where the mouse is. It only seems to happen there, though.



  • @danixdefcon5 said:

     It only seems to happen there, though.

     

    I have an idea. Get a real browser.

    Seriously, there is nothing wrong, tested on IE and FF.  And even if there was, I fail to see how it would be relevant.


Log in to reply