"Daniel Fournier" <[EMAIL PROTECTED]> a �crit dans le message de news:[EMAIL PROTECTED] > Benoit Quenneville wrote: > > how to get selection and replace it by html string! > > > > Thank! > > --------------------------------------- > > Benoit Quenneville > > > > > > > You have to use the DOM level 2 Traversal-Range specification nicely > implemented in Mozilla. > > The spec: > <http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/> > > You can use for instance: > > var range = > document.getElementById('editor_widget_ID').contentWindow.getSelection().get RangeAt(0); > > to retrieve the selected element in the editor window. > > Then if the selection begins with an html element, you can just do: > > var htmlNode = range.startContainer; > htmlNode.innerHTML = '<b>anHTMLstring</b>'; > > But instead of inserting a raw HTML string, you had better create the > HTML node(s) you want to insert with the DOM2 document.createElement() > method and use the range insertNode method. > > For instance: > > var bold = document.createElement('B'); > bold.appendChild(document.createTextNode('anHTMLstring')); > range.insertNode(bold); > > > Daniel >
Merci bien cousin Fran�ais de ces infomations tr�s appr�ci�s! --------------------------------------- Benoit Quenneville (Qu�bec, Canada)
