[Javascript] Text range object
Andrew Gibson
andyg at ihug.co.nz
Wed May 22 04:55:24 CDT 2002
I'm trying to replace the HTML code in a text range
say I select some text "<b>test</b>"
// this selects the range
var r=document.selection.createRange()
// this can delete the text in the range
r.text=""
but leaves the html portion as "<b></b>"
I gather r.textHTML is a read only property so I can't change it that way!
I wan to be able to remove or edit the html portion
eg
"<b>text</b>" >> "text"
I know I can do this through something like this
document.execCommand("Bold") which toggles the <b> on and off
but on some other commands, it throws in some unwanted <P> which mucks up
the display!
Andrew
More information about the Javascript
mailing list