我目前在 CKEditor 4.5.8 配置文件中使用以下代码来删除 <svg>
和 <script>
来自在 CKEditor 中编辑的 HTML 内容的标签。
config.allowedContent = {
$1: {
// Use the ability to specify elements as an object.
elements: CKEDITOR.dtd,
attributes: true,
styles: true,
classes: true
}
};
config.disallowedContent = 'svg;script;';
当这些标签包含在 <body>
中时,它们都被剥离得很好, 但标签在包含在 <head>
中时全部保留.我特别担心<script>
一直在附近。
CKEditor应该如何配置来剥离<script>
来自 <head>
的标签?我是否缺少一些更深层次的配置元素?提前致谢!
最佳答案
在初始化 CKEditor 时添加额外的参数。如果你想编辑整个 HTML 页面,这是必要的,使用 <html>
, <head>
和 <body>
元素,你需要设置 config.fullPage
选项为真:
config.allowedContent = {
$1: {
// Use the ability to specify elements as an object.
elements: CKEDITOR.dtd,
attributes: true,
styles: true,
classes: true,
fullPage: true
}
};
关于javascript - 如何配置 CKEditor 从 <head> 中去除 <script> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46178245/