1.index.htmljavascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>完整demo</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script> <!--建議手動加在語言,避免在ie下有時由於加載語言失敗致使編輯器加載失敗--> <!--這裏加載的語言文件會覆蓋你在配置項目裏添加的語言類型,好比你在配置項目裏配置的是英文,這裏加載的中文,那最後就是中文--> <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script> </head> <body> <form action="index.php" method="post"> <script id="editor" type="text/plain" style="width:1024px;height:500px;" name="content"></script> <input type="submit" value="提交"> </form> <script type="text/javascript"> //實例化編輯器 //建議使用工廠方法getEditor建立和引用編輯器實例,若是在某個閉包下引用該編輯器,直接調用UE.getEditor('editor')就能拿到相關的實例 //修改toolbars 工具欄的自定義 var ue = UE.getEditor('editor',{ toolbars:[[ 'undo', //撤銷 'redo', //重作 'bold', //加粗 'fontfamily', //字體 'fontsize', //字號 'emotion', //表情 'spechars', //特殊字符 ],[ 'justifyleft', //居左對齊 'justifyright', //居右對齊 'justifycenter', //居中對齊 'justifyjustify', //兩端對齊 'forecolor', //字體顏色 'insertcode', //代碼語言 'simpleupload', //單圖上傳 'insertimage', //多圖上傳 'insertvideo', //視頻 ]], autoHeightEnabled:false, isshow:true, //initialContent:'hello world', focus:true, //readonly:true, enableAutoSave:true, saveInterval:100, }) </script> </body> </html>
2.index.phpphp
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- 引入文件 --> <script type="text/javascript" src="third-party/SyntaxHighlighter/shCore.js"></script> <link rel="stylesheet" href="third-party/SyntaxHighlighter/shCoreDefault.css"> <title></title> </head> <body> <?php echo $_POST['content']; ?> </body> <script type="text/javascript"> SyntaxHighlighter.all();//代碼高亮 </script> </html>