1. 程式人生 > >ueditor 編輯器,自定義圖片上傳

ueditor 編輯器,自定義圖片上傳

action () scree val ech idt tof height 使用

  1. <div>
  2. <h1>完整demo</h1>
  3. <form method="post" name="form">
  4. <div id="editor" name="content" style="width:800px;height:500px"></div>
  5. <div id="editor2" name="content" style="width:800px;height:500px"></div>
  6. </form>
  7. </div>
  8. <div><input type="button" value="提交" onclick="t()"></input></div>
  9. 三、創建ue對象實例
  10. <script type="text/javascript">
  11. //實例化編輯器
  12. //建議使用工廠方法getEditor創建和引用編輯器實例,如果在某個閉包下引用該編輯器,直接調用UE.getEditor(‘editor‘)就能拿到相關的實例
  13. var ue = UE.getEditor(‘editor‘,{
  14. toolbars: [
  15. [‘source‘,‘subscript‘,‘superscript‘, ‘undo‘, ‘redo‘, ‘bold‘, ‘snapscreen‘,‘preview‘, ‘simpleupload‘,‘insertimage‘, ‘emotion‘,
  16. ‘spechars‘, ‘drafts‘ , ‘time‘,‘date‘]
  17. ],
  18. autoHeightEnabled: true,
  19. autoFloatEnabled: true,
  20. imageActionName:‘testUpload‘//定義上傳的action名稱
  21. });
  22. UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
  23. UE.Editor.prototype.getActionUrl = function(action) {
  24. if (action == ‘testUpload‘) {//跳轉到後來的上傳action
  25. return ‘${pageContext.request.contextPath}/testEditor/testUpload.action‘;
  26. } else {
  27. return this._bkGetActionUrl.call(this, action);
  28. }
  29. }
  30. function t(){
  31. form.action="${pageContext.request.contextPath }/testEditor/testForm.action";
  32. form.submit();
  33. }
  34. </script>

ueditor 編輯器,自定義圖片上傳