Is there any way to retain line breaks and white space when asking the
browser to return the textContent from JS in ffox?
thx,
D.
heres what I've tried so far...
function MakePlainText(el)
{
el.style.whiteSpace="pre"
tmp = document.all ? el.innerText : el.textContent
alert(tmp) // the whitespace and breaks are already gone
by here in ffox.
tmp = tmp.replace(/[\n]/gi,'\n\n')
alert(tmp)
tmp = tmp.replace(/(Plain Text)/gi,'')
el.innerHTML = '<textarea READONLY style="width:100%;"
rows="20">' + tmp.replace(/[\n\r][\n\r][\n\r][\n\r][\n\r]/gi,'') + '</
textarea>'
//alert(el.id.split('TARGET')[0])
window.location.href="#" + el.id.split('TARGET')[0]
}
I have found this and my though is I'm screwed...
textContent of type DOMString, introduced in DOM Level 3
This attribute returns the text content of this node and its
descendants. When it is defined to be null, setting it has no effect.
On setting, any possible children this node may have are removed and,
if it the new string is not empty or null, replaced by a single Text
node containing the string this attribute is set to.
On getting, no serialization is performed, the returned string
does not contain any markup. No whitespace normalization is performed
and the returned string does not contain the white spaces in element
content (see the attribute Text.isElementContentWhitespace).
Similarly, on setting, no parsing is performed either, the input
string is taken as pure textual content.
The string returned is made of the text content of this node
depending on its type, as defined below:
Any thoughts?