CKEDITOR,在文本编辑器 onLoad 上自动聚焦
有人知道如何在页面加载时自动聚焦于 CKEDITOR 文本区域吗?
目前,用户必须先单击文本区域才能开始输入。像 Google 一样,我希望加载页面,并且用户可以立即开始输入,而无需单击文本区域。
这是启动 CKEDITOR 的当前代码
<script type="text/javascript">
CKEDITOR.replace( 'meeting_notes',
{
toolbar :
[
[ 'Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
['Cut','Copy','Paste','PasteText'],
['Undo','Redo','-','RemoveFormat'],
['TextColor','BGColor'],
['Maximize']
]
});
</script>
谢谢
Anyone know how to autofocus on the CKEDITOR text area on page load?
Currently the user has to click in the text area before they can start typing. Like Google, I'd like the page to load and the user can immediately start typing w/o having to click the text area.
Here is the current code that initiated CKEDITOR
<script type="text/javascript">
CKEDITOR.replace( 'meeting_notes',
{
toolbar :
[
[ 'Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
['Cut','Copy','Paste','PasteText'],
['Undo','Redo','-','RemoveFormat'],
['TextColor','BGColor'],
['Maximize']
]
});
</script>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
也许是
startupFocus
配置选项?Perhaps the
startupFocus
config option?我自己没有尝试过,但请查看 CKEDITOR.config .startupFocus。
定义:设置页面加载时编辑器是否应该具有焦点。
I've not tried it myself, but check out the CKEDITOR.config.startupFocus.
Definition: Sets whether the editor should have the focus when the page loads.
在您的配置中只需执行以下操作:
In your config simply do this:
通过将回调传递给将焦点设置到编辑器的
onReady
属性,将焦点设置到加载时的编辑器set focus to the editor on load by passing a callback to the
onReady
prop that sets focus to the editor来自 CKEditor 5 文档: 使编辑器获得焦点的最简单方法是调用 editor.focus() 方法。
from CKEditor 5 docs: The simplest way to focus the editor is to call the editor.focus() method.