如何在所见即所得模式下滚动 CKEditor?
我正在构建一个网站,一些页面包含 CKEditor 的实例(即 WYSIWYG 编辑器)。到目前为止他们工作得很好。尽管如此,事实是有时我需要将编辑区域滚动到底部而不需要用户交互(即从外部事件处理程序的主体内以编程方式执行滚动)。
问:
- 滚动 CKeditor 的正确方法是什么(即我应该使用什么方法) 所见即所得编辑器?页面可能有多个实例,我只是要求 滚动特定的编辑器实例。
PS:我在文档中找不到任何内容,谷歌搜索也没有任何帮助:(。
I'm building a site and some pages include instances of CKEditor (i.e. the WYSIWYG editor) . They are working fine so far. Nonetheless the fact is that sometimes I need to scroll edit area right to the bottom without requiring user interaction (i.e. perform scrolling programmatically from within the body of an external event handler) .
Q:
- What's the right way (i.e. what method should I use) to scroll CKeditor
WYSIWYG editor ? Page may have multiple instances, I'm just asking for
scrolling a particular editor instance .
PS: I couldn't find anything in the docs, and Googling didn't help at all :( .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Olemis
我不知道官方的方式,但设法劫持了劫持 - 我真丢脸 - http://ckeditor.com/demo 和以下代码适用于 IE/FF(恐怕你得尝试其他浏览器),
其中“ifr”是我在运行时为 iframe 指定的名称。好消息是,这两个浏览器都支持出色的开发工具和一个可以创造奇迹的 js 控制台...
现在,CKEditor 框架没有正确的 id,但它包含的元素有(在该演示中,它是一个 TD id'编辑“cke_contents”)。里程可能会有所不同。这表明你可以用 jquery 来调味。
让我知道这个“黑客”是否正常工作,否则我们希望有人能提供一些可行的代码。
问候
Olemis
I don't know of an official way, but managed to hijack - shame on me- the CKEditor at http://ckeditor.com/demo and the following code worked for IE/FF (you gotta try other browsers I'm afraid)
where "ifr" is a name I gave at runtime to the iframe. Great news that both browsers support great developer tools and a js console that works wonders...
Now, the CKEditor frame doesn't have a proper id, but the element it is contained in does (in that demo it is a TD id'ed "cke_contents"). Mileage may vary. That suggests you can spicy it up with jquery.
Let me know if that 'hack' properly works, otherwise let's hope someone comes with some workable code.
Regards
我知道这是一个旧问题,但它显示在我最近回答的一个新问题上。从那里复制以供将来参考:我可以访问 jQuery,这可能会起作用。
这种方法与之前的答案非常相似。这假设CKE>1。 4.x,因为它使用 CKEDITOR.instances 点表示法,但您可以使用以下表示法将其与旧版本一起使用:
CKEDITOR.instances["editor1"]
。在这里,您使用 CKE 实例并从那里获取引用文档。非 jquery 也应该可行,但现在不能打扰。如果你想要原生 JS,请添加评论:)I know this is an old Q, but it showed up as related on a newer one I recently answered. To copy from there for future reference: I you have access to jQuery, this might do the trick.
This method is very similar to the earlier answer. This assumes CKE > 4.x, because it uses CKEDITOR.instances dot notation, but you can use this with oldr versions using this notation:
CKEDITOR.instances["editor1"]
. Here you use the CKE instance and grab the referring document from there. Should be doable non-jquery as well, but can't be bothered right now. If you want native JS, add a comment :)