using textrange to stop tr's being selectable

F

foldface

Hi
I have a table and I've been trying to find a way to stop the text
in the
table being selectable.
One article nearly works for me:

http://groups.google.co.uk/groups?h...306291340.629e932%40posting.google.com&rnum=6

But not quite. The code below shows my problem:

<table width=50% border=groove>
<tr OnMouseDown='OnMouseDown()'>
<td>hi</td>
</tr>
</table>

<script>
function OnMouseDown() {
var obj = window.event.srcElement;
var r = document.body.createTextRange();
r.moveToElementText(obj);
r.select();
return true;
}

</script>

This code seems to stop the selection by effectively selecting the
text before hand, selecting text twice == select/unselect. The problem
is when you press
the ctrl key then selecting the text twice == select/select, i.e. it
stays selected.
So all I want to do is stop text being selected when the ctrl key is
pressed,
any ideas?

Thanks
F
 
F

foldface

Thomas 'PointedEars' Lahn said:
[...]
any ideas?

Why is it that some people think they can mess with
the program of the user without any disadvantage?


PointedEars

The users would -never- want to select text in my particular case, I'm not
doing this to be clever but to workaround an IE idiosyncrasy
 
T

Thomas 'PointedEars' Lahn

The users would -never- want to select text in my particular case, I'm
not doing this to be clever

For that would prove the exact opposite.
but to workaround an IE idiosyncrasy

Which is? Maybe you are asking the wrong question.


PoointedEars
 
T

Thomas 'PointedEars' Lahn

The users would -never- want to select text in my
particular case, I'm not doing this to be clever

For what you are doing would prove the exact opposite.
but to workaround an IE idiosyncrasy

Which is? Maybe you are asking the wrong question.


PointedEars
 
M

Martin Honnen

I have a table and I've been trying to find a way to stop the text
in the
table being selectable.

For IE/Win you should try whether
<td onselectstart="return false;">
or
<table onselectstart="return false;">
is all you need.
 
F

foldface

For IE/Win you should try whether
<td onselectstart="return false;">
or
<table onselectstart="return false;">
is all you need.

it does -exactly- what I want :)
Thanks
F
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top