標籤:
文字編輯器:可以從網上下載---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 文字編輯器