[Javascript] Text range object

Cory Mercurio Cory.Mercurio at KronosCompany.com
Tue May 28 12:40:54 CDT 2002


Hello, Andrew. Did you ever find a solution to your problem?

Bests,
-cory-

-----Original Message-----
From: Andrew Gibson [mailto:andyg at ihug.co.nz] 
Sent: Wednesday, May 22, 2002 2:55 AM
To: javascript at LaTech.edu
Subject: [Javascript] Text range object


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




_______________________________________________
Javascript mailing list
Javascript at LaTech.edu https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list