Stopping mouse selecting text

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

    Stopping mouse selecting text

    Is there any way to stop someone getting their mouse and selecting
    text on a page (without making the text an image of course). Is it
    possible to trap and stop click-and-drag functionality from the mouse?

    Bit of a stranger request but can it be done? :)

    Cheers
    Ryan
  • Vjekoslav Begovic

    #2
    Re: Stopping mouse selecting text

    Something like this:

    <script type="text/javascript">
    mClicked=false
    </script>

    <body onmousedown="mC licked=true" onmuseup="mClic ked=false" onmousemove="if
    (mClicked) alert('Disabled '); mClicked=false" >

    "RelaxoRy" <relaxory@postm aster.co.uk> wrote in message
    news:3ba42c06.0 307300317.28127 7db@posting.goo gle.com...[color=blue]
    > Is there any way to stop someone getting their mouse and selecting
    > text on a page (without making the text an image of course). Is it
    > possible to trap and stop click-and-drag functionality from the mouse?
    >
    > Bit of a stranger request but can it be done? :)
    >
    > Cheers
    > Ryan[/color]


    Comment

    • Richard Cornford

      #3
      Re: Stopping mouse selecting text

      "RelaxoRy" <relaxory@postm aster.co.uk> wrote in message
      news:3ba42c06.0 307300317.28127 7db@posting.goo gle.com...[color=blue]
      >Is there any way to stop someone getting their mouse and
      >selecting text on a page (without making the text an image
      >of course). Is it possible to trap and stop click-and-drag
      >functionalit y from the mouse?[/color]
      [color=blue]
      > Bit of a stranger request but can it be done? :)[/color]

      Yes and No. IE browsers have events like onselectstart and ondragstart
      that can be cancelled, effectively inhibiting the selection of content.
      Opera, on the other hand, has no mechanism for doing anything of the
      sort.

      You will have to explain why you want to prevent text selection because
      you are probably attempting to solve the wrong problem and explaining
      what the real problem is would enable people to suggest ways of solving
      it.

      Richard.



      Comment

      • David Dorward

        #4
        Re: Stopping mouse selecting text

        Vjekoslav Begovic wrote:
        [color=blue]
        > "RelaxoRy" <relaxory@postm aster.co.uk> wrote[/color]
        [color=blue][color=green]
        >> Is there any way to stop someone getting their mouse and selecting
        >> text on a page[/color][/color]
        [color=blue]
        > Something like this:[/color]

        <snip> JS </script>

        Of course, if the objective is to stop people copy/pasting the content, its
        a fruitless endeavour. There is nothing to stop people from viewing the
        source or turning JS off.



        --
        David Dorward http://david.us-lot.org/
        Which is stupider: Pop-up ads claiming they'll stop spam, or spam claiming
        it'll stop pop-up ads? -- Dork Tower

        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: Stopping mouse selecting text

          relaxory@postma ster.co.uk (RelaxoRy) writes:
          [color=blue]
          > Is there any way to stop someone getting their mouse and selecting
          > text on a page (without making the text an image of course). Is it
          > possible to trap and stop click-and-drag functionality from the mouse?[/color]

          Generally, no.

          Some browsers has event handlers like "ondragstar t" which can be
          canceled. Others don't. In all cases, turning off Javascript will
          stop that attempt.
          [color=blue]
          > Bit of a stranger request but can it be done? :)[/color]

          IN some situations, yes. In general, no.
          In general, you shouldn't want to interfere with the users' way
          of using a browser.

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          Working...