iframe 中元素的 CKEditor 内联编辑器

2024-04-22

在应用程序中,我在 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');
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iframe 中元素的 CKEditor 内联编辑器 的相关文章

随机推荐