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

Home Posts Topics Members FAQ

IE text range selection

I have a Content Management SYstem that allows users to modify
code/content through a standard "<textarea>" text box. Sometimes, when
they select text (to copy, delete, etc.) they grab on to partial HTML
tags. This causes confusion and messes up the updates they make.

Is there a way to check a selected text range, and if it has a partial
tag selected, to change the selection automatically to the complete tag
or no tag?

Specifically, upon mouseup when a selection is made, check if the
leftmost and rightmost selections include "><", in which case the
selection will be reduced by 1 char (on whichever side) so the partial
tag is not included.

It only needs to work in IE 5.5+. (Intranet with uniform PC setups.)

I have no problem reading selected text, and determining if it contains
partial tags, the problem is in modifying the selected/highlighted text
in the textarea.

Thank you,
A.L.

Jul 23 '05 #1
3 2306
Ivo
<aq********@gmail.com> wrote
It only needs to work in IE 5.5+. (Intranet with uniform PC setups.)

I have no problem reading selected text, and determining if it contains
partial tags, the problem is in modifying the selected/highlighted text
in the textarea.


Look into the moveStart() and moveEnd() methods of the textrange object. See
(mind the wrap)
<
http://msdn.microsoft.com/workshop/a...hods/movestart.
asp >

hth
--
Ivo


Jul 23 '05 #2
Thanks Ivo, I am giving things a shot based on that link.

If anyone has working code for text ranges using moveStart() and
moveEnd() methods that'd be great!

In the mean time, I will see what I can do on my own...

Thanks,
A.L.
Jul 23 '05 #3
Thanks to Ivo and others I was able to find a working solution. To see
it, follow a thread I started April 1, 2005 in comp.lang.javascript
called:

Changing selected text in textarea

Code samples from Martin Honnen and myself are included in the
thread...

Thanks,
A.L.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I...
2
by: Mark Szlazak | last post by:
The following code fails in Firefox to get at selected text in the right-side textarea. Any help would be appreciated. <html> <head> <script> var agt = navigator.userAgent.toLowerCase();...
5
by: aqualizard | last post by:
I have searched and searched and searched... Can someone please tell me how (or "if" it is even possible) to change selected text in a textarea? Specifically, say a user has highlighted "ppl"...
2
by: sasperilla | last post by:
Hi, I would like to find the coordinates of a word inside a div or span tag. I know you can find the coordinates of a tag inside the DOM, but can you get the coordinates of a portion of the...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
3
by: trpost | last post by:
I want to be able to select a word when I highlight over any part of the word. When I say select the word, I want it to be highlighted as if I left clicked my mouse and dragged the cursor along the...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
3
by: Dekortage | last post by:
Hi all... I am able to grab the text that a user has selected on a web page, using this code: function moreInfo() { if (!isIE) { var t = window.getSelection(); // act on variable "t";
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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.