Copying plain text from a WYSIWYGI to a normal textarea?
I know I did ask this question earlier but here is my problem in details:
- if I copy the text from textarea1 to textarea2 using a JavaScript program, it works fine
- if I开发者_如何学C attach the teaxtarea1 with a WYSIWYG editor then it refuses to work. And I am using openWYSIWYG.
Why can't I can copy the plain text from textarea1 when it is attached to a WYSIWYG?
The code I am using for copying it without a WYSIWYG is:
function postChange() {
document.forms["form1"].textarea2.value = document.forms["form1"].textarea1.value;
}
I don't know this "WYSIWYG", although I think I know what you mean. Could it be that when you apply it to a textarea, said textarea's value no longer holds the text? The text is probably in some property of the WYSIWYG object. Or something.
Can you post a link to the library?
And look what I found in their "Save" code:
WYSIWYG.updateTextArea(n);
Try with that and then get the value of the textarea.
That's because what you see isn't a textarea but an iframe with a full HTML page inside.
There is a hidden textarea, but it doesn't seem to be updated in real time.
The method given by Rew should work (for Firefox, that's contentDocument) but it returns HTML code (generated by the widget), not plain text.
You might want to use body.plainText (instead of body.innerHTML) on Firefox, not sure for other browsers.
Alternatively, check your widget's API to see if they don't offer such plain text access.
精彩评论