Is it possible to determine the caret position, in terms of x/y
pixels, within a textarea? (I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
-Derik
(OTOH, finding the Caret position-- between what characters the cursor
is positioned-- uses the function below. I include it to be nice to
future searchers, and because it took me an hour of frustrated
searching to find.)
function getCaretPos(el) {
if (typeof el.selectionSta rt != 'undefined')
return el.selectionSta rt;
else if (document.selec tion)
return
Math.abs(docume nt.selection.cr eateRange().mov eStart('charact er',
-1000000));
} 3 8464
ReGenesis0 wrote:
Is it possible to determine the caret position, in terms of x/y
pixels, within a textarea? (I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
I do not think it is generally possible to determine the coordinates
of the caret since you cannot always know which font is used.
I would be confused if the suggestion box would move while I am typing, so
it should suffice to calculate the offset position and height of the control.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>
Le 9/28/08 4:11 PM, ReGenesis0 a écrit :
Is it possible to determine the caret position, in terms of x/y
pixels, within a textarea? (I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
I don't know if ... but :
<http://www.quirksmode. org/js/findpos.html>
--
sm
On Sep 28, 9:59*am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
ReGenesis0 wrote:
Is it possible to determine the caret position, in terms of x/y
pixels, within a textarea? *(I want to have a suggestion box pop up
under where you're typing... so i need to determine where you are
typing.)
I do not think it is generally possible to determine the coordinates
of the caret since you cannot always know which font is used.
*grumble*
I would be confused if the suggestion box would move while I am typing, so
it should suffice to calculate the offset position and height of the control.
It's a *large* textarea box. Placing the popup at top or bottom would
require scrolling the browser.
Is there a method for determining the rows then? Just hovering the
box below the current line would probably work...
-Derik This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Krzysztof Kujawski |
last post by:
Hi
Is there posibility to (and how to do this):
a) add a string in the current cursor position?
b) add string before and after selection in textarea e.g. selection
c) if I put with value+='' how to move cursor to position after ] and
before [
|
by: AP |
last post by:
I am trying to find the integer value for the cursor position in a text box,
in particular I want to find out if I am at the end of some text that I
typed or at the beginning.
I am using IE 6.
Thanks,
Andy
|
by: Thomas |
last post by:
Hi there,
I'd like to insert a text into a textarea at the current cursor position
when you click on a button, but I only found out how to insert a text at
the end of the textarea. Is it possible to insert text at cursor position
and if it is, how can I do it?
Thanks for any help
|
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 at
http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam12032001.asp
in the chapter "O Cursor, Where Art Thou".
|
by: Ilann |
last post by:
Hi,
I need to get the text cursor position in a richedit Control, ie I want my
ContextMenu to appear exactly where the user is typing text,
Thanks
| |
by: DaveR |
last post by:
Can anybody help me to a)get the user's cursor insertion point (caret)
from a multiline textbox, using client-side script I suppose, and then
b)return the position to VB code behind?
I have tried the following client-side function suggested on this
Google Group (thank you) but I'm not sure what it's doing or how to
return the caret position to code behind ("txtReading" is the Textbox
ID):
function getcaretpos(txtReading)
|
by: Doug Bell |
last post by:
Hi,
How do I get the position of the cursor (as character position) when it is
in a text box with no text selected?
Thanks
Doug
|
by: gsb58 |
last post by:
Hi!
I'm new to VB.NET
Anybody that could show me how to find the cursor position in a
RichEdit?
That is: when user click anywhere in the box and there's some text
already, I want to programatically move to a new line and insert time,
make a new line and user will be ready to insert new text.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |