> What the documentation doesn't note is that, if you create a
> new range, the range is created at the beginning of the text
> area. So when you create a new textRange in your textarea,
> the range is at at 0-0, so a negative number will move to to
> 0 (negative values don't
> work) and a positive number will move from the start point of
> the textbox - not the selection.
Err.. ok, that's right. My bad. But...
> In order to get the cursor positioned, you want to move
> relative to the selection (it'll be relative to the end of
> the seelction, regardless of the direction the text was
> selected in), and then reselect the text range. I'm not sure
> why that works, but it does (if this wasn't IE and it's pile
> of quirks, I'd research it until I knew - but it's probably
> "just the way it is" rather than for any good reason). Use
> these two lines instead of your last line where you create a
> new area, and it should work better.
>
> aSel.move('character',-4)
> aSel.select();
Nope, still does bzactly the same thing. Also tried...
..humm....
...hang on, I didn't have that aSel.select(); in there...
Well I'll be a monkeys... Whatever...
It was the missing .select() that was tripping me up. I guess you can move
the range as you please, but until you tell it to become the selection...
Well, yes, now that I read the docs over again, that is exactly what it
says...
Thanks! But...
Now I have another problem. While I was waiting for a reply here, I came up
with another solution that I like better... I think...
I added the following:
if (aSel.text=='') {
aSel.moveStart('character',-100000);
if (aSel.text.lastIndexOf(startTxt) > aSel.text.lastIndexOf(endTxt))
startTxt='';
else
endTxt='';
aSel.collapse(false);
}
So that if you are outside of a bold block, it adds only the and if you
are inside the bold, it adds only the . E.g. if you click the B you get
first then you can type your text and when you click the B the second
time you get
Which do you think is better?
I also added hotkeys: Ctrl+B for Bold, Ctrl+I for italic, etc...
---
James Newton: PICList webmaster/Admin
mailto:jamesnewton@piclist.com 1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist