问题
My extension, in a content script, writes to the subject and message body of the Google Groups "New Topic" page.
The updated subject is displayed just fine; it's of input type "text", so everything is easy. The body, however, is a div representing a TextBox, and when I write to it, the update doesn't appear:
(Click for a larger image.)
I tried setting the focus to the field first, but that had no effect.
回答1:
How are you trying to set the text? Show your code!
A typical way to initially set a contenteditable
element is like so:
var messageBody = document.getElementById ("p-b-0");
messageBody.innerHTML = '<p>Line 1.</p><p>Line 2.</p>';
Note that using innerHTML
erases anything that might have been on the textbox before -- which is okay for this question's scenario.
(For more advanced changes/edits, load jQuery and use it to add/delete/replace nodes inside the edit box. But, that is a subject for a different search and/or question.)
来源:https://stackoverflow.com/questions/13592263/text-gets-set-in-google-groups-post-message-body-but-does-not-display