Re: setSelectionRange and friends
- From: David Mark <dmark.cinsoft@xxxxxxxxx>
- Date: Sat, 30 May 2009 10:35:54 -0700 (PDT)
On May 30, 1:29 pm, Tim Streater <timstrea...@xxxxxxxxxxxx> wrote:
In article <4A20611C.50...@xxxxxxxxxxxxxx>,
Thomas 'PointedEars' Lahn <PointedE...@xxxxxx> wrote:
Tim Streater wrote:
I'm aiming to replicate what Mac-Eudora does when you start to type in
an e-mail address into as it might be the To: field. If Eudora
recognises that you seem to be typing in a nickname that it can expand,
it:
1) completes the nickname and highlights the extra characters it has
entered
2) makes that whole nickname <strong>, or bold (but not the rest of the
To: line)
3) allows you to continue typing to complete the nickname or type a
comma to accept it and have it expanded
4) as you type, the highlighted area shrinks one char to the right at a
time
In thinking how I might do this, using onkeypress and onkeyup, I come
across setSelectionRange, startSelection and endSelection for use with a
textarea that I think might be useful in this context (found by some
amount of googling). But none of these is documented as far as I can
tell in for example Danny Goodman's or David Flanagan's JavaScript books.
Maybe because those books are junk, dumped in shelves by wannabes?
(rhetorical question)
Is this part of a foolish war about which books are best?
IMO: Goodman's is better laid out and has more detail. But having two
books is better than none. And while a pure reference (ECMA's or anyone
else's) is good, they tend to be rather skeletal.
That said, the property names are "selectionStart" and "selectionEnd",
respectively. They are well-documented at MDC as they are native to XUL.
<https://developer.mozilla.org/en/XUL/Method/setSelectionRange>
<https://developer.mozilla.org/en/XUL/Property/selectionStart>
<https://developer.mozilla.org/en/XUL/Property/selectionEnd>
Yes, I found this. Flanagan makes one reference to XUL which eventually
leads to the URLs above. Useful as a reference but I could find little
discussion.
These seem to work in Safari 4 beta and FF3 (both Mac), but I'm
concerned they might be deprecated or not be best suited for my needs -
or that they might be part of a useful and well supported set that for
some reason I'm going to have to discover one item at a time.
They are certainly proprietary, but since they have been used, you don't
have to be afraid that they are going away anytime soon. Just be aware of
it and do feature-test them before accessing them (you should do that anyway).
Well, faute de mieux I shall press on with these. Hopefully not as fast
as the Titanic, though.
Iceberg, right ahead (says "XUL" on it.) Use the objects I suggested.
.
- Follow-Ups:
- Re: setSelectionRange and friends
- From: Thomas 'PointedEars' Lahn
- Re: setSelectionRange and friends
- References:
- Re: setSelectionRange and friends
- From: Thomas 'PointedEars' Lahn
- Re: setSelectionRange and friends
- Prev by Date: Re: Computed shortcut styles
- Next by Date: Re: Timed Redirect with warning to multiple pages
- Previous by thread: Re: setSelectionRange and friends
- Next by thread: Re: setSelectionRange and friends
- Index(es):
Relevant Pages
|
Loading