I was toying with building a TEXTAREA replacement that used GIF images
as fonts, so I needed to figure out a lot of cursor position
manipulation.
Here is a function that may work for you:
function getSelectedHTML() {
var rng=null
var html="";
if(document.selection&&document.selection.createRange){
rng=document.selection.createRange();
html=rng.htmlText||"";
}
else if (window.getSelection) {
rng=window.getSelection();
if (rng.rangeCount > 0 && window.XMLSerializer){
rng=rng.getRangeAt(0);
html=new XMLSerializer().serializeToString(rng.cloneContents());
}
}
if(html!='''') {
alert(html)
var myChars = document.getElementsByClassName(''hasCursor'',$
(''editor''));
if(myChars.length>0) {
mi = myIndex($(myChars[0]).id)
copyClip(decodeTXT(html))
}
}
return html;
}
On Jan 12, 3:31 pm, AlexGuru
<foral...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi everyone,
>
> If anybody now if i can (and how) get position of selected text in
> some html element, for example <div>?
> Thankyou.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---