The next character after a range

21 views
Skip to first unread message

Eric Kean

unread,
May 26, 2013, 11:19:13 AM5/26/13
to ra...@googlegroups.com
Hello,

I'm trying to get the next character after a selected range.  Before discovering rangy, I posted my question on stackoverflow, and someone posted the solution:

window.getSelection().focusNode.textContent.charAt(window.getSelection().focusOffset);

Though it worked great in Safari, after reading up a bit, I understand that this type of solution won't work for earlier versions of IE.  With this in mind, I'm hoping to implement rangy, and was wondering if there's a way to get the next character after a selected range using the "rangy object".

Thanks so much,

Eric

Nico Burns

unread,
May 27, 2013, 6:47:20 PM5/27/13
to ra...@googlegroups.com
I think Rangy is supposed to implement the DOM range standard, so the above might well work as is (replacing window with 'rangy'). Not sure about this though. An IE way of doing things would be:

​document.selection.createRange().collapse(false).moveEnd("character", 1).text​​

​Nico​






--
You received this message because you are subscribed to the Google Groups "rangy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rangy+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Eric Kean

unread,
May 27, 2013, 7:49:17 PM5/27/13
to ra...@googlegroups.com
Thank you for the reply!  I'll try out your suggestion.


 

Reply all
Reply to author
Forward
0 new messages