...

View Full Version : how to get character before cursor



homerUK
03-16-2004, 12:28 PM
I am trying to work out a way of returning the character BEFORE the cursor position using an onkeypress command.

for example:

th|


if the pipeline above is the cursor - when the user types the next letter, I want to be able to get the letter before that. So in this case, the script would return "h"

I've tried using some of the following commands:



var code = iView.document.selection;
var tmp = code.createRange();

tmp.expand("character",1);


but nothing seemed to work.

any help is much appreciated.... thanks :)

Willy Duitt
03-16-2004, 02:15 PM
Try the forum Search (http://www.codingforums.com/search.php?s=). This question was asked and resolved approximately a month ago. I'm sure you will find your answer there.

.....Willy

homerUK
03-16-2004, 02:18 PM
oh god!! It was me that asked the question as well!!!

:rolleyes: :rolleyes: :rolleyes:

*stupid*

sorry about that!!!! :eek:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum