[thelist] Javascript - Clearing formatting from a text selection

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Wed Aug 2 21:03:38 CDT 2006


		Hi Ann,

   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;
 }

Cheers,

Peter

				From: Ann Adamcik daadamcik at yahoo.com

Hi,

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. 

I think I need something like execCommand('RemoveFormat'), but the text is not editable. Does anyone have any ideas on how to go about doing this?

There's a demo page here: http://indigopear.com/lib/selected.html
And the script file is here: http://indigopear.com/lib/selections.js

Thanks very much!
-Ann



More information about the thelist mailing list