| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=8">
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
- <title>重置编辑器</title>
- <script type="text/javascript" charset="utf-8" src="../editor_config.js"></script>
- <script type="text/javascript" charset="utf-8" src="editor_api.js"></script>
- <link rel="stylesheet" type="text/css" href="../themes/default/ueditor.css"/>
- <style type="text/css">
- #simple {
- width: 1000px;
- border: 1px solid #ddd;
- }
- </style>
- </head>
- <body>
- <h2>重置编辑器和销毁编辑器示例</h2>
- <div class="content" id="simple"></div>
- <p><input type="button" onclick="simple()" value="重置编辑器内部参数"><span id="txt"></span></p>
- <p><input id="destroy" type="button" onclick="destroy()" value="销毁编辑器"></p>
- <script type="text/javascript" charset="utf-8">
- var editor = new baidu.editor.ui.Editor();
- editor.render( "simple" );
- function simple() {
- editor.setContent("编辑器内部变量已经被重置!");
- editor.reset();
- }
- function destroy(){
- editor.destroy();
- var button = document.getElementById("destroy");
- button.value = "重新渲染";
- button.onclick = function(){
- editor = new baidu.editor.ui.Editor();
- editor.render( "simple" );
- this.value="销毁编辑器";
- this.onclick = destroy;
- }
- }
- function setMsg() {
- document.getElementById( "txt" ).innerHTML = "编辑器当前保存了 <span style='color: red'> " + editor.undoManger.list.length + " </span>次操作";
- }
- setInterval( setMsg, 100 );
- </script>
- </body>
- </html>
|