Scroll to the bottom of ckeditor

做~自己de王妃 提交于 2020-01-04 13:58:10

问题


any ideas on how to scroll to bottom of a ckeditor editor using javascript / jQuery?

I cant find anything.

All my search shows is:

document.getElementById("ID").contentWindow.scrollTo(0,3);

Which gives me an error of contentWindow is undefined.

The class of the ckeditor text part appears to be "cke_editable".

Any help on scrolling to the bottom of the editor?


回答1:


Access the editor and get the editable area via that instead of getting the DOM element directly. Like so:

var editor = CKEDITOR.instances.editor1; 
var jqDocument = $(editor.document.$);
var documentHeight = jqDocument.height();
jqDocument.scrollTop(documentHeight);

This works in the Demo: http://ckeditor.com/demo (you need var $ = jQuery; if you try it in the console).

Note that your editor might not be named "editor1" - use the appropriate name for you.



来源:https://stackoverflow.com/questions/25900395/scroll-to-the-bottom-of-ckeditor

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