473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ 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='On MouseDown()'>
<td>hi</td>
</tr>
</table>

<script>
function OnMouseDown() {
var obj = window.event.sr cElement;
var r = document.body.c reateTextRange( );
r.moveToElement Text(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 2407
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*********@nu rfuerspam.de> wrote in message news:<40******* *******@Pointed Ears.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
9858
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 ********************************** package Celcom.Client;
6
10802
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=> tags around the selected text. Easier said than done. My first though was to do a search and replace on the innerHTML, but falls down if there is...
5
10883
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 appreciated. Thanks. Atara. ------------------------- Original code:
5
3715
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. When the user clicks the "Add another email" it will call a client side JavaScript function, add_email, which will dynamically add a new set of...
2
2472
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 Visual Studio .NET 2005's Design View always hides the <tr>'s regardless of whether the ASP:Panel's Visible property is set to True, False, or not set...
3
3978
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 with a createElement function to add additional entries. The table has the first row of input text boxes already in it. You have to click a button to...
14
4226
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 something I'm missing header-wise that keeps me from making this work on my work system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do...
1
2763
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 item. If I do not set the verticalpadding property, the items are rendered too close to one another. However, when I set the verticalpadding...
10
2219
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 an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) {...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7449
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5069
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
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 we have to send another system
1
1037
muto222
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.