Connecting Tech Pros Worldwide Forums | Help | Site Map

using textrange to stop tr's being selectable

foldface@yahoo.co.uk
Guest
 
Posts: n/a
#1: Jul 23 '05
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

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#2: Jul 23 '05

re: using textrange to stop tr's being selectable


foldface@yahoo.co.uk wrote:[color=blue]
> [...]
> any ideas?[/color]

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


PointedEars
foldface@yahoo.co.uk
Guest
 
Posts: n/a
#3: Jul 23 '05

re: using textrange to stop tr's being selectable


Thomas 'PointedEars' Lahn <PointedEars@nurfuerspam.de> wrote in message news:<40B92ACE.7090608@PointedEars.de>...[color=blue]
> foldface@yahoo.co.uk wrote:[color=green]
> > [...]
> > any ideas?[/color]
>
> Why is it that some people think they can mess with
> the program of the user without any disadvantage?
>
>
> PointedEars[/color]

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
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#4: Jul 23 '05

re: using textrange to stop tr's being selectable


foldface@yahoo.co.uk wrote:
[color=blue]
> The users would -never- want to select text in my particular case, I'm
> not doing this to be clever[/color]

For that would prove the exact opposite.
[color=blue]
> but to workaround an IE idiosyncrasy[/color]

Which is? Maybe you are asking the wrong question.


PoointedEars
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#5: Jul 23 '05

re: using textrange to stop tr's being selectable


foldface@yahoo.co.uk wrote:
[color=blue]
> The users would -never- want to select text in my
> particular case, I'm not doing this to be clever[/color]

For what you are doing would prove the exact opposite.
[color=blue]
> but to workaround an IE idiosyncrasy[/color]

Which is? Maybe you are asking the wrong question.


PointedEars
Martin Honnen
Guest
 
Posts: n/a
#6: Jul 23 '05

re: using textrange to stop tr's being selectable




foldface@yahoo.co.uk wrote:

[color=blue]
> I have a table and I've been trying to find a way to stop the text
> in the
> table being selectable.[/color]

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/

foldface@yahoo.co.uk
Guest
 
Posts: n/a
#7: Jul 23 '05

re: using textrange to stop tr's being selectable


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

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