从控制台将文本插入 TinyMCE
Insert text into TinyMCE from console
此问题是已回答问题 的后续问题。
我正在尝试通过控制台半自动完成 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>
这是一个示例文档,它将 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>
此问题是已回答问题
我正在尝试通过控制台半自动完成 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>
这是一个示例文档,它将 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>