0

这个问题是从这里回答的问题的后续。

我正在尝试通过控制台半自动完成 Web 表单。我不能使用 Selenium 或任何其他需要安装的工具。我希望能够将整个代码长度粘贴到控制台中,并在我按 Enter 时自动完成所有内容。

我想我已经把大部分都整理好了。我必须解决的最后一个难题是如何将文本输入到 TinyMCE 文本框中。我相信文本区域的 ID 是“colour_summary”。对于其他文本框,我已成功使用:

document.getElementById('textbox').value = hello;

但同样的方法不适用于 TinyMCE 文本框。我什至不确定我是否包含网页的正确部分,但以下是我的最佳猜测。感谢任何建议。

tinyMCE.init({
  mode: "exact",
  language: "en",
  elements: "colour_summary",
  plugins: "table,advimage,advlink,flash",
  theme: "advanced",
  theme_advanced_toolbar_location: "top",
  theme_advanced_toolbar_align: "left",
  theme_advanced_path_location: "bottom",
  theme_advanced_buttons1: "justifyleft,justifycenter,justifyright,justifyfull,separator,bold,italic,strikethrough,separator,sub,sup,separator,charmap",
  theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,image,flash,separator,cleanup,removeformat,separator,code",
  theme_advanced_buttons3: "tablecontrols",
  extended_valid_elements: "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]",
  relative_urls: false,
  debug: false
  
  ,width:550,height:350,cleanup_on_startup:true,theme:"advanced",theme_advanced_toolbar_location: "top",theme_advanced_toolbar_align:"left",theme_advanced_path_location:"bottom",theme_advanced_blockformats:"h3,h4,h5",theme_advanced_buttons1:"cut,copy,paste,pasteword,pastetext,separator,undo,redo,separator,bold,italic,underline,separator,sub,sup,separator,charmap,removeformat,code,separator,link,unlink,image,hr",theme_advanced_buttons2:"fontsizeselect,styleselect,forecolor,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull,spellchecker",plugins:"paste,table,advlink,advimage,spellchecker",paste_create_paragraphs:true,paste_create_linebreaks:true,paste_auto_cleanup_on_paste: true,paste_convert_middot_lists:true,paste_convert_headers_to_string:true,file_browser_callback : "ajaxfilemanager",relative_urls:true,content_css:"/css/frontend/select_styles.css",apply_source_formatting:true
});
//]]>
</script><textarea name="colour[summary]" id="colour_summary" rows="10" cols="45"></textarea>    </div>
</div>
4

1 回答 1

0

这是一个示例文档,它将 html 格式的文本写入网页上的 tinyMCE 框。

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
  <script>tinymce.init({selector:'textarea'});</script>
</head>
<body onload="writeToTinyMCE()">

  <textarea name="colour[summary]" id="colour_summary" rows="10" cols="45"></textarea>      

<script>
function writeToTinyMCE() {
  doc=document.getElementsByTagName("iframe")[0];
  doc.contentDocument.documentElement.innerHTML;  
  doc.contentDocument.documentElement.innerHTML = "<p>Sample <b>Bold</b> <i>italic</i></p><p>New Para</p>";
}
</script>




</body>
</html>
于 2021-02-06T18:56:41.900 回答