resetDemo.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=8">
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  7. <title>重置编辑器</title>
  8. <script type="text/javascript" charset="utf-8" src="../editor_config.js"></script>
  9. <script type="text/javascript" charset="utf-8" src="editor_api.js"></script>
  10. <link rel="stylesheet" type="text/css" href="../themes/default/ueditor.css"/>
  11. <style type="text/css">
  12. #simple {
  13. width: 1000px;
  14. border: 1px solid #ddd;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <h2>重置编辑器和销毁编辑器示例</h2>
  20. <div class="content" id="simple"></div>
  21. <p><input type="button" onclick="simple()" value="重置编辑器内部参数"><span id="txt"></span></p>
  22. <p><input id="destroy" type="button" onclick="destroy()" value="销毁编辑器"></p>
  23. <script type="text/javascript" charset="utf-8">
  24. var editor = new baidu.editor.ui.Editor();
  25. editor.render( "simple" );
  26. function simple() {
  27. editor.setContent("编辑器内部变量已经被重置!");
  28. editor.reset();
  29. }
  30. function destroy(){
  31. editor.destroy();
  32. var button = document.getElementById("destroy");
  33. button.value = "重新渲染";
  34. button.onclick = function(){
  35. editor = new baidu.editor.ui.Editor();
  36. editor.render( "simple" );
  37. this.value="销毁编辑器";
  38. this.onclick = destroy;
  39. }
  40. }
  41. function setMsg() {
  42. document.getElementById( "txt" ).innerHTML = "编辑器当前保存了 <span style='color: red'> " + editor.undoManger.list.length + " </span>次操作";
  43. }
  44. setInterval( setMsg, 100 );
  45. </script>
  46. </body>
  47. </html>