473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

from caret to textRange object

Hi all,

in a DHTML Editing control (MSIE), I need to "extend" the caret to the
nearest text character in order to obtain a text selection (and than a
textRange object with the createRange method).

This is needed because I have a set of functions doing operations
within the edit control's rich text. But all the functions need to
start from a selected text (for example, adding a table row). My aim is
to get the things work also if no text is selected from the user. But I
could not find a way to have a selected text starting from the simple
cursor position. Any suggestion?

many thanks,

giovanni

Jul 23 '05 #1
1 3016
Hi

Hmm, not sure if this helps, or if I have understood correctly, but..

My understanding is that "document.selection" represents the current
selection or cursor position, and that a cursor is just a collapsed
range (i.e. same start and end point)..

http://msdn.microsoft.com/workshop/a...asp?frame=true

Thus:-

if (document.selection)
{
oCursorRange=document.selection.createRange();
}

You then use the MSIE TextRange methods

e.g.

oCursorRange.expand

http://msdn.microsoft.com/workshop/a...ods/expand.asp

You can also do this:-

oCursorRange.collapse(true);// If you want to make sure it is
collapsed.

Does this help?

Julian

Jul 23 '05 #2

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

Similar topics

2
by: Bambam6235 | last post by:
Hi all, I would like to determine where the current insertion point is in a text field. Say I had a text field that held 80 characters. I would like to display to the user the current...
4
by: torch | last post by:
I have trawled the internet for a solution to this one . All I need is the caret position as a number. I have seen quite a few text insertion functions that do something like this : ...
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=>...
7
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example...
3
by: ocomet | last post by:
Hi Everyone.. I want to know how can I use regular expression in TextRange Object. I wrote specific word highlighting code and it is working now. but this is static word highlighting. I...
1
by: Steve | last post by:
Hi, Person A has $60,000 person B has $70,000 and this sentence now ends. If a user clicks on the "000" of the $60,000, is there any way to associate that with the entire monetary unit...
2
by: randy | last post by:
Hi, I'm trying to set up a richtextbox to behave like the text area in a web browser, i.e. no caret, and a cursor that changes depending on what it's hovering over. I've been setting the...
8
by: Dave | last post by:
Hi all, I have a problem with DOM. If I have the xy coordinates in a web page, how can I get (possibly using Javascript) the corresponding word placed into the web page at the given...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.