PDA

View Full Version : removing html tags



nolsie
29 Oct 2007, 5:06 AM
how do I remove the html tags when I display text in a TextArea? :-/

para
29 Oct 2007, 5:34 AM
You could try something like


function stripTags(str) {
str = str.replace(/<.*>/g, '');
return str;
}

I think that should remove all instances of <.*> from the string.

There wouldn't be a way to get them back, however.

dolittle
29 Oct 2007, 5:42 AM
maybe htmldecode?
http://extjs.com/deploy/ext/docs/output/Ext.util.Format.html#htmlDecode

nolsie
30 Oct 2007, 1:47 AM
I decided to use stripTags, but I get a [object Object] in the TextArea!



dsDocument.on('load', function(){
var str = Ext.util.Format;
str.stripTags(dsDocument.getAt(0).data.content );

content_field.setValue(str);
form.render('document');
});


content_field is my TextArea.

tryanDLS
30 Oct 2007, 7:49 AM
Set a BP on that line and verify that you're actually passing a string to stripTags.