473,471 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using textrange to stop tr's being selectable

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
6 2405
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
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
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
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


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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
6
by: sentinel | last post by:
Hi, I’m trying to modify a DHTML editor that parses a style-sheet via PHP and instead of modifying the tags via execCommand(), find a way of writing inline styles by way of adding <span style=>...
5
by: Atara | last post by:
I am trying to convert the following code to VB .Net, I still have some gaps (the lines that are marked with (*)) and also I need an ending condition for the while loop. any help would be...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
2
by: Nathan Sokalski | last post by:
I have an HTML table in which I am using ASP:Panel controls to group together <tr>'s so that I can more easily show/hide them (by setting the ASP:Panel's Visible property). This works fine, but...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
14
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be...
1
by: Homer | last post by:
Hi, I used a template for my first Web application. I made a few changes to the layer thru its css file. The problem that has been vexing me is the vertical spacing for each navigation menu...
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.