2017-08-07 84 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> 

希望這會幫助別人:)