Thinkphp 文字編輯器

來源:互聯網
上載者:User

標籤:

文字編輯器:可以從網上下載---ueditor檔案夾裡麵包含php和utf8-php兩個檔案夾平時使用時主要用到擷取內容和寫入內容兩個按鈕擷取內容:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title>  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.config.js"></script>  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.all.min.js"> </script>    <!--建議手動加在語言,避免在ie下有時因為載入語言失敗導致編輯器載入失敗-->    <!--這裡載入的語言檔案會覆蓋你在設定項目裡添加的語言類型,比如你在設定項目裡配置的是英文,這裡載入的中文,那最後就是中文-->   <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/lang/zh-cn/zh-cn.js"></script></head><body><div><!--文字編輯器顯示地區-->    <script id="editor" type="text/plain" style="width:800px;height:300px;"></script></div><div> <button onclick="getContent()">獲得內容</button> <button onclick="setContent()">寫入內容</button> </div><div id="xianshi"></div></body><script type="text/javascript">//執行個體化文字編輯器,這句話必須有var ue = UE.getEditor(‘editor‘);function getContent() {    //主要作用語句        //在文字編輯器中寫入內容,點擊獲得內容按鈕後,在xianshi<div>裡顯示內容document.getElementById("xianshi").innerHTML = UE.getEditor(‘editor‘).getContent();}       </script></html>
View Code文字編輯器中寫入的內容:

 

xianshi<div>中現實的內容:

 

寫入內容:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title>  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.config.js"></script>  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.all.min.js"> </script>    <!--建議手動加在語言,避免在ie下有時因為載入語言失敗導致編輯器載入失敗-->    <!--這裡載入的語言檔案會覆蓋你在設定項目裡添加的語言類型,比如你在設定項目裡配置的是英文,這裡載入的中文,那最後就是中文-->   <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/lang/zh-cn/zh-cn.js"></script></head><body><div><!--文字編輯器顯示地區-->    <script id="editor" type="text/plain" style="width:800px;height:300px;"></script></div><div> <button onclick="getContent()">獲得內容</button> <button onclick="setContent()">寫入內容</button> </div><div id="xianshi"></div></body><script type="text/javascript">//執行個體化文字編輯器,這句話必須有var ue = UE.getEditor(‘editor‘);       function setContent(isAppendTo) {  var str = "<p style=‘white-space: normal;‘><span style=‘background-color: rgb(84, 141, 212);‘>斯柯達晶高科的複活節</span><img src=‘http://localhost:8080/ueditor/php/upload/image/20160704/1467600934975616.png‘ title=‘1467600934975616.png‘ alt=‘6.png‘></p><p style=‘white-space: normal;‘><span style=‘text-decoration: underline; color: rgb(0, 176, 80);‘><em>看電視劇趕快回家回家的撒</em></span></p><p><br></p>"; //主要作用語句UE.getEditor(‘editor‘).setContent(str, isAppendTo);}</script></html>
View Code寫入內容前現實的內容:

擷取內容代碼加到對應的方法中,然後寫入內容,顯示一樣的內容:

Thinkphp 文字編輯器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.