By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,701 Members | 1,782 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,701 IT Pros & Developers. It's quick & easy.

using textrange to stop tr's being selectable

P: n/a
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?hl...com%26rnum%3D6

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
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
fo******@yahoo.co.uk wrote:
[...]
any ideas?


Why is it that some people think they can mess with
the program of the user without any disadvantage?
PointedEars
Jul 23 '05 #2

P: n/a
Thomas 'PointedEars' Lahn <Po*********@nurfuerspam.de> wrote in message news:<40**************@PointedEars.de>...
fo******@yahoo.co.uk wrote:
[...]
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
Jul 23 '05 #3

P: n/a
fo******@yahoo.co.uk wrote:
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
Jul 23 '05 #4

P: n/a
fo******@yahoo.co.uk wrote:
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
Jul 23 '05 #5

P: n/a


fo******@yahoo.co.uk wrote:

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

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

Jul 23 '05 #6

P: n/a
> 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
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.