Stopping mouse selecting text

R

RelaxoRy

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
 
V

Vjekoslav Begovic

Something like this:

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

<body onmousedown="mClicked=true" onmuseup="mClicked=false" onmousemove="if
(mClicked) alert('Disabled'); mClicked=false">
 
R

Richard Cornford

RelaxoRy said:
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? :)

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.
 
L

Lasse Reichstein Nielsen

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?

Generally, no.

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

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

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,569
Members
47,206
Latest member
MalorieSte

Latest Threads

Top