Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

js: html string to plaintext

79 views
Skip to first unread message

gNeandr

unread,
Nov 8, 2009, 7:54:11 PM11/8/09
to
Any pointer for javascript routine to convert a html string to plain text?
eg: <a class="moz-txt-link-abbreviated"
href="some...@foo.xyz">some...@foo.xyz</a>
to get just "some...@foo.xyz"


Gijs Kruitbosch

unread,
Nov 9, 2009, 6:12:37 AM11/9/09
to

element.textContent should do what you want, if you have an element reference...
If you don't, you could use domparser to get one, or (if you have a document)
create a span, and set its innerHTML, and then inspect textContent on it. I
don't know of an interface that gets you that info directly from an html string.

~ Gijs

gNeandr

unread,
Nov 9, 2009, 6:57:29 AM11/9/09
to
Hi Gijs,

thanks for the info .. unfortunately it doesn't help at that point.
It should be used for parsing an string I read form ICS data which looks
like:
"ORGANIZER:<a class=\"moz-txt-link-freetext\"
href=\"MAILTO:some...@foo.xyz\">MAILTO:some...@foo.xyz</a>"

My current code fails -- also I remember it worked well in the past. I
was not aware an html string is passed in at that point.
I expected a string like
"ORGANIZER;CN=\"some name\":mailto:some...@foo.xyz"

So a domparserwouldn't help either. Any other idea??

G�nter

PS Venkman + ReminderFox (1.9.5) still blocks if not started in right
order ... have posted to the other group before .. will come back to it
later

0 new messages