Text gets set in Google Groups, post-message body but does not display?

南笙酒味 提交于 2019-12-24 02:34:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!