2017-08-07 65 views
0

之间的内容经过几天的搜索和尝试解决,无处可寻。CKEditor删除<title></title>标签

CKEditor 4.7.0正在剥离<title></title>标签之间的内容。 无论使用标题标签的方式/位置如何,我都需要CKEDitor离开标题内容。

我曾尝试:

  • allowedContent:真,
  • extraAllowedContent: '标题',
  • extraAllowedContent: '标题[*]',
  • config.allowedContent = TRUE; (在config.js中)
  • CKEDITOR.dtd。$ removeEmpty ['title'] = false; (在config.js中)

没有上面的运气。然后试图暗示这里ckeditor deteles page <title></title> title其工作原理,但我结束了:

<!DOCTYPE html> 
<html> 
<head> 
    <title>OK Title</title> 
</head> 
<body>&nbsp;</body> 
</html> 
<p><br /> 
<title></title> 
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Web template presented with pure css."><meta name="keywords" content="css template"></p> 
<link href="style.css" rel="stylesheet" /> 
<link href="red.css" rel="stylesheet" /> 
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" /><!-- Header --> 
<header class="w3-container w3-theme w3-padding" id="myHeader"> 
<div class="w3-center"> 
<h4>BEAUTIFUL RESPONSIVE WEB SITES</h4> 

什么我做的是从https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_templates_black&stacked=h

我明白这个粘贴到CKEditor的一个例子CSS模板是不一样标准的HTML应显示(不是规范),但我需要阻止CKEditor修改标题标签,无论如何,只要忽略它,让我在任何地方使用它:)这只是一个简单的项目,教室里没有人看到页面源,我需要当我在白板上为学生投影页面时,标题标签显示在浏览器选项卡中。

更新:确实发现,如果我在视图中保存源代码,CKEditor不会修改标题标签。以这种方式工作,但不是当在视觉模式,喜欢有:)

回答

0

之后似乎无尽的搜索发现在一个复制论坛上的一些信息。有这么多的链接打开丢失的确切网站获得信息的轨道,对不起。

解决通过添加以下到我的config.js中的CKEditor 4.7.0问题:

config.allowedContent = true; 
config.protectedSource.push(/<title>[\s\S]*?<\/title>/gi); // allow content between <title></title> 

希望这会帮助别人:)