滚动到ckeditor的底部 [英] Scroll to the bottom of ckeditor

查看:268
本文介绍了滚动到ckeditor的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关如何使用javascript / jQuery滚动到ckeditor编辑器底部的任何想法?

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

我找不到任何东西。

我的搜索结果是:

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

这给我一个错误的contentWindow是未定义的。

Which gives me an error of contentWindow is undefined.

ckeditor文本部分的类似于cke_editable。

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

滚动到编辑器底部的任何帮助?

Any help on scrolling to the bottom of the editor?

推荐答案

访问编辑器,通过它获取可编辑区域,而不是直接获取DOM元素。像这样:

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);

这适用于演示: http://ckeditor.com/demo (你需要 var $ = jQuery; 如果你在控制台中尝试)。

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

请注意,您的编辑器可能没有命名为editor1 - 使用适当的名称。

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

这篇关于滚动到ckeditor的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆