sso

index.html 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. <title>完整demo</title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  7. <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
  8. <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
  9. <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
  10. <style type="text/css">
  11. div{
  12. width:100%;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <div>
  18. <h1>完整demo</h1>
  19. <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
  20. </div>
  21. <div id="btns">
  22. <div>
  23. <button onclick="getAllHtml()">获得整个html的内容</button>
  24. <button onclick="getContent()">获得内容</button>
  25. <button onclick="setContent()">写入内容</button>
  26. <button onclick="setContent(true)">追加内容</button>
  27. <button onclick="getContentTxt()">获得纯文本</button>
  28. <button onclick="getPlainTxt()">获得带格式的纯文本</button>
  29. <button onclick="hasContent()">判断是否有内容</button>
  30. <button onclick="setFocus()">使编辑器获得焦点</button>
  31. <button onmousedown="isFocus(event)">编辑器是否获得焦点</button>
  32. <button onmousedown="setblur(event)" >编辑器失去焦点</button>
  33. </div>
  34. <div>
  35. <button onclick="getText()">获得当前选中的文本</button>
  36. <button onclick="insertHtml()">插入给定的内容</button>
  37. <button id="enable" onclick="setEnabled()">可以编辑</button>
  38. <button onclick="setDisabled()">不可编辑</button>
  39. <button onclick=" UE.getEditor('editor').setHide()">隐藏编辑器</button>
  40. <button onclick=" UE.getEditor('editor').setShow()">显示编辑器</button>
  41. <button onclick=" UE.getEditor('editor').setHeight(300)">设置高度为300默认关闭了自动长高</button>
  42. </div>
  43. <div>
  44. <button onclick="getLocalData()" >获取草稿箱内容</button>
  45. <button onclick="clearLocalData()" >清空草稿箱</button>
  46. </div>
  47. </div>
  48. <div>
  49. <button onclick="createEditor()">
  50. 创建编辑器</button>
  51. <button onclick="deleteEditor()">
  52. 删除编辑器</button>
  53. </div>
  54. <script type="text/javascript">
  55. //实例化编辑器
  56. //建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
  57. var ue = UE.getEditor('editor');
  58. function isFocus(e){
  59. alert(UE.getEditor('editor').isFocus());
  60. UE.dom.domUtils.preventDefault(e)
  61. }
  62. function setblur(e){
  63. UE.getEditor('editor').blur();
  64. UE.dom.domUtils.preventDefault(e)
  65. }
  66. function insertHtml() {
  67. var value = prompt('插入html代码', '');
  68. UE.getEditor('editor').execCommand('insertHtml', value)
  69. }
  70. function createEditor() {
  71. enableBtn();
  72. UE.getEditor('editor');
  73. }
  74. function getAllHtml() {
  75. alert(UE.getEditor('editor').getAllHtml())
  76. }
  77. function getContent() {
  78. var arr = [];
  79. arr.push("使用editor.getContent()方法可以获得编辑器的内容");
  80. arr.push("内容为:");
  81. arr.push(UE.getEditor('editor').getContent());
  82. alert(arr.join("\n"));
  83. }
  84. function getPlainTxt() {
  85. var arr = [];
  86. arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
  87. arr.push("内容为:");
  88. arr.push(UE.getEditor('editor').getPlainTxt());
  89. alert(arr.join('\n'))
  90. }
  91. function setContent(isAppendTo) {
  92. var arr = [];
  93. arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
  94. UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
  95. alert(arr.join("\n"));
  96. }
  97. function setDisabled() {
  98. UE.getEditor('editor').setDisabled('fullscreen');
  99. disableBtn("enable");
  100. }
  101. function setEnabled() {
  102. UE.getEditor('editor').setEnabled();
  103. enableBtn();
  104. }
  105. function getText() {
  106. //当你点击按钮时编辑区域已经失去了焦点,如果直接用getText将不会得到内容,所以要在选回来,然后取得内容
  107. var range = UE.getEditor('editor').selection.getRange();
  108. range.select();
  109. var txt = UE.getEditor('editor').selection.getText();
  110. alert(txt)
  111. }
  112. function getContentTxt() {
  113. var arr = [];
  114. arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
  115. arr.push("编辑器的纯文本内容为:");
  116. arr.push(UE.getEditor('editor').getContentTxt());
  117. alert(arr.join("\n"));
  118. }
  119. function hasContent() {
  120. var arr = [];
  121. arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
  122. arr.push("判断结果为:");
  123. arr.push(UE.getEditor('editor').hasContents());
  124. alert(arr.join("\n"));
  125. }
  126. function setFocus() {
  127. UE.getEditor('editor').focus();
  128. }
  129. function deleteEditor() {
  130. disableBtn();
  131. UE.getEditor('editor').destroy();
  132. }
  133. function disableBtn(str) {
  134. var div = document.getElementById('btns');
  135. var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
  136. for (var i = 0, btn; btn = btns[i++];) {
  137. if (btn.id == str) {
  138. UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
  139. } else {
  140. btn.setAttribute("disabled", "true");
  141. }
  142. }
  143. }
  144. function enableBtn() {
  145. var div = document.getElementById('btns');
  146. var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
  147. for (var i = 0, btn; btn = btns[i++];) {
  148. UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
  149. }
  150. }
  151. function getLocalData () {
  152. alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
  153. }
  154. function clearLocalData () {
  155. UE.getEditor('editor').execCommand( "clearlocaldata" );
  156. alert("已清空草稿箱")
  157. }
  158. </script>
  159. </body>
  160. </html>