How to disable text selection?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kj

    #1

    How to disable text selection?




    Is there any way to disable text selection in a web page (or at
    least render it invisible to the user)?

    If there is a way to control how selected text and its background
    are rendered, then the desired effect could be achieved by setting
    these parameters to match those of regular text. In this way, even
    if text was selected, the user would not see that it was.

    Thanks!

    kj
  • Martin Honnen

    #2
    Re: How to disable text selection?



    kj wrote:[color=blue]
    > Is there any way to disable text selection in a web page (or at
    > least render it invisible to the user)?[/color]

    There are browser dependant ways, example using CSS extensions for
    Mozilla/Netscape and using script for IE5+:

    <p>Normal paragraph.</p>
    <p onselectstart=" return false;"
    style="-moz-user-select: none;">
    Paragraph where selection is disabled.
    </p>

    Of course browser users can disable script or have user stylesheets
    overriding your CSS settings.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Fabian

      #3
      Re: How to disable text selection?

      kj hu kiteb:
      [color=blue]
      > Is there any way to disable text selection in a web page (or at
      > least render it invisible to the user)?
      >
      > If there is a way to control how selected text and its background
      > are rendered, then the desired effect could be achieved by setting
      > these parameters to match those of regular text. In this way, even
      > if text was selected, the user would not see that it was.[/color]

      Please think carefully before you do this. All too often, web authors
      use colour/background schemes that are hard to read, and sometimes
      choose colour schemes that are impossible for colour blind people. For
      these people, the fact that the colours do change is a valuable user
      interface tool.


      --
      --
      Fabian
      Visit my website often and for long periods!


      Comment

      • DU

        #4
        Re: How to disable text selection?

        kj wrote:
        [color=blue]
        > Is there any way to disable text selection in a web page (or at
        > least render it invisible to the user)?
        >
        > If there is a way to control how selected text and its background
        > are rendered, then the desired effect could be achieved by setting
        > these parameters to match those of regular text. In this way, even
        > if text was selected, the user would not see that it was.
        >
        > Thanks!
        >
        > kj[/color]

        What you're asking is definitively not recommendable. It's clearly goes
        against standard basic browser functionality. Whatever you do with
        javascript or CSS can be overriden by the user.

        FWIW, in Windows XP, only the user can set the background color (and
        text color) of selected text:

        Start/Settings/Control Panel/Display/Appearance tab/Advanced
        button/Item:/Selected Items and here
        Item: ... color 1
        Font: ... color

        DU

        Comment

        Working...