示例: http://ueditor.baidu.com/website/onlinedemo.htmlphp
引用代碼: window.UMEDITOR_HOME_URL = $CONFIG['domain'] + "/res/local/js/ueditor/"; //注意就是這裏!
window.UEDITOR_CONFIG.imageUrl = $CONFIG['domain'] + '/goodspic?type=2';
window.UEDITOR_CONFIG.savePath= ['upload'];
window.UEDITOR_CONFIG.imagePath = $CONFIG['domain'] + '/res/local/uploads/';
UE.getEditor('addArea')
UE.getEditor('areaBottom')html
示例代碼web
var domUtils = UE.dom.domUtils; var ServerUrl = '/server/ueditor/'; var options = { //圖片上傳配置區 serverUrl:ServerUrl+"controller.php" ,imageUrl:ServerUrl+"imageUp.php" //圖片上傳提交地址 ,imagePath:ServerUrl //圖片修正地址,引用了fixedImagePath,若有特殊需求,可自行配置 //塗鴉圖片配置區 ,scrawlUrl:ServerUrl+"scrawlUp.php" //塗鴉上傳地址 ,scrawlPath:ServerUrl+"" //圖片修正地址,同imagePath //附件上傳配置區 ,fileUrl:ServerUrl+"fileUp.php" //附件上傳提交地址 ,filePath:ServerUrl //附件修正地址,同imagePath ,catchRemoteImageEnable: false // ,catcherUrl:ServerUrl +"getRemoteImage.php" //處理遠程圖片抓取的地址 // ,catcherPath:ServerUrl //圖片修正地址,同imagePath ,imageManagerUrl:ServerUrl + "imageManager.php" //圖片在線管理的處理地址 ,imageManagerPath:ServerUrl //圖片修正地址,同imagePath ,snapscreenHost: location.hostname //屏幕截圖的server端文件所在的網站地址或者ip,請不要加http:// ,snapscreenServerUrl: ServerUrl +"imageUp.php" //屏幕截圖的server端保存程序,UEditor的範例代碼爲「ServerUrl +"server/upload/snapImgUp.php"」 ,snapscreenPath: ServerUrl ,snapscreenServerPort: location.port //屏幕截圖的server端端口 ,wordImageUrl:ServerUrl + "imageUp.php" //word轉存提交地址 ,wordImagePath:ServerUrl // ,getMovieUrl:ServerUrl+"getMovie.php" //視頻數據獲取地址 ,videoUrl:ServerUrl+"fileUp.php" //附件上傳提交地址 ,videoPath:ServerUrl, //附件修正地址,同imagePath lang:/^zh/.test(navigator.language || navigator.browserLanguage || navigator.userLanguage) ? 'zh-cn' : 'en', langPath:UEDITOR_HOME_URL + "lang/", disabledTableInTable: false, webAppKey:"9HrmGf2ul4mlyK8ktO2Ziayd", initialFrameWidth:860, initialFrameHeight:400, focus:true, shortcutMenu:["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"] }; function setLanguage(obj) { var value = obj.value, opt = { lang:value }; UE.utils.extend(opt, options, true); UE.delEditor("editor"); //清空語言 if (!UE._bak_I18N) { UE._bak_I18N = UE.I18N; } UE.I18N = {}; UE.I18N[opt.lang] = UE._bak_I18N[ opt.lang ]; UE.getEditor('editor', opt); } function isFocus(e){ alert(UE.getEditor('editor').isFocus()); UE.dom.domUtils.preventDefault(e) } function setblur(e){ UE.getEditor('editor').blur(); UE.dom.domUtils.preventDefault(e) } function insertHtml() { var value = prompt('插入html代碼', ''); UE.getEditor('editor').execCommand('insertHtml', value) } function createEditor() { enableBtn(); UE.getEditor('editor', { initialFrameWidth:"100%" }) } function getAllHtml() { alert(UE.getEditor('editor').getAllHtml()) } function getContent() { var arr = []; arr.push("使用editor.getContent()方法能夠得到編輯器的內容"); arr.push("內容爲:"); arr.push(UE.getEditor('editor').getContent()); alert(arr.join("\n")); } function getPlainTxt() { var arr = []; arr.push("使用editor.getPlainTxt()方法能夠得到編輯器的帶格式的純文本內容"); arr.push("內容爲:"); arr.push(UE.getEditor('editor').getPlainTxt()); alert(arr.join('\n')) } function setContent(isAppendTo) { var arr = []; arr.push("使用editor.setContent('歡迎使用ueditor')方法能夠設置編輯器的內容"); UE.getEditor('editor').setContent('歡迎使用ueditor', isAppendTo); alert(arr.join("\n")); } function setDisabled() { UE.getEditor('editor').setDisabled('fullscreen'); disableBtn("enable"); } function setEnabled() { UE.getEditor('editor').setEnabled(); enableBtn(); } function getText() { //當你點擊按鈕時編輯區域已經失去了焦點,若是直接用getText將不會獲得內容,因此要在選回來,而後取得內容 var range = UE.getEditor('editor').selection.getRange(); range.select(); var txt = UE.getEditor('editor').selection.getText(); alert(txt) } function getContentTxt() { var arr = []; arr.push("使用editor.getContentTxt()方法能夠得到編輯器的純文本內容"); arr.push("編輯器的純文本內容爲:"); arr.push(UE.getEditor('editor').getContentTxt()); alert(arr.join("\n")); } function hasContent() { var arr = []; arr.push("使用editor.hasContents()方法判斷編輯器裏是否有內容"); arr.push("判斷結果爲:"); arr.push(UE.getEditor('editor').hasContents()); alert(arr.join("\n")); } function setFocus() { UE.getEditor('editor').focus(); } function deleteEditor() { disableBtn(); UE.getEditor('editor').destroy(); } function disableBtn(str) { var div = document.getElementById('btns'); var btns = domUtils.getElementsByTagName(div, "button"); for (var i = 0, btn; btn = btns[i++];) { if (btn.id == str) { domUtils.removeAttributes(btn, ["disabled"]); } else { btn.setAttribute("disabled", "true"); } } } function enableBtn() { var div = document.getElementById('btns'); var btns = domUtils.getElementsByTagName(div, "button"); for (var i = 0, btn; btn = btns[i++];) { domUtils.removeAttributes(btn, ["disabled"]); } } function getLocalData () { alert(UE.getEditor('editor').execCommand( "getlocaldata" )); } function clearLocalData () { UE.getEditor('editor').execCommand( "clearlocaldata" ); alert("已清空草稿箱") } window.onkeydown = function (e){ if (!ue.isFocus()) { var keyCode = e.keyCode || e.which; if (keyCode == 8) { e.preventDefault(); } } };