[thelist] Javascript - Clearing formatting from a text selection

Ann Adamcik daadamcik at yahoo.com
Thu Aug 3 20:52:22 CDT 2006

Hi Peter,

Thanks very much for your reply!  Actually, I think I got it figured it out.  In case anyone else is interested, here's the pertinent bit:

   if (range.selectNodeContents) {    // Mozilla
       var parent = span.parentNode; 
       parent.replaceChild(range.extractContents(), span);
   else if (range.moveToElementText) {        // IE

----- Original Message ----
From: Peter Brunone (EasyListBox.com) <peter at easylistbox.com>
Are you looking for something like this (equivalent to IE's innerText property)?

function filterHTML(sText) {
 sText = sText.replace(/<\/?\s*[^>]*>/gi, "" );
 sText = sText.replace(/&nbsp;/, " ");
 sText = sText.replace(String.fromCharCode(160), "");
 return sText;

 From: Ann Adamcik daadamcik at yahoo.com
I'm implementing a feature that will allow users to insert comments into a block of text. It works by wrapping a text selection in a span tag, and adding a class and title. So far, so good, (at least with browsers other than Safari...), but I also need to allow users to delete their comments.

More information about the thelist mailing list