Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Text range object


  • From: javascript@xxxxxxxxxx (Andrew Gibson)
  • Subject: [Javascript] Text range object
  • Date: Wed, 22 May 2002 21:55:24 +1200

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