在一个应用程序中,我在 iframe 中有内容可编辑的元素,我想将内联 CKEditor 应用于这些元素。它有效,除非我滚动 iframe,CKEditor 工具栏不随它滚动。是否有特殊标志或某种方式让工具栏随 iframe 内容而不是随父窗口滚动?此外,我想避免将 CKEditor 脚本添加到 iframe 中。
最佳答案
您可以通过使用与 iframe 大小相同且具有相对定位的容器元素包装 iframe 来实现这一点。
<div id="iframe-wrapper">
<iframe>
<body>
<div contenteditable></div>
</body>
</iframe>
</div>
然后将每个 ckeditor 面板的位置移动到该容器元素中,绝对定位值将起作用。
var el = $('iframe').contents().find('[contenteditable]');
el.ckeditor();
el.ckeditorGet().on('instanceReady', function(){
$('body > .cke_float').appendTo('#iframe-wrapper');
});
关于javascript - iframe 中元素的 CKEditor 内联编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19416016/