JavaScript的execCommand指令集–http://www.yongfa365.com/Item/JavaScript-execCommand.html

來源:互聯網
上載者:User
  1. /*  
  2. *該function執行copy指令  
  3. */  
  4. function fn_doufucopy(){   
  5. edit.select();   
  6. document.execCommand('Copy');   
  7. }   
  8. /*  
  9. *該function執行paste指令  
  10. */  
  11. function fn_doufupaste() {    
  12. tt.focus();   
  13. document.execCommand('paste');   
  14. }    
  15. /*  
  16. *該function用來建立一個超連結  
  17. */  
  18. function fn_creatlink()   
  19. {   
  20.   document.execCommand('CreateLink',true,'true');//彈出一個對話方塊輸入URL   
  21.   //document.execCommand('CreateLink',false,'http://www.51js.com');   
  22. }   
  23. /*  
  24. *該function用來將選中的區塊設為指定的背景色  
  25. */  
  26. function fn_change_backcolor()   
  27. {   
  28.   document.execCommand('BackColor',true,'#FFbbDD');//true或false都可以   
  29. }   
  30. /*  
  31. *該function用來將選中的區塊設為指定的前景色彩,改變選中區塊的字型大小,改變字型,字型變粗變斜  
  32. */  
  33. function fn_change_forecolor()   
  34. {   
  35. //指定前景色彩   
  36. document.execCommand('ForeColor',false,'#BBDDCC');//true或false都可以   
  37. //指定背景色   
  38. document.execCommand('FontSize',false,7);   //true或false都可以   
  39. //字型必須是系統支援的字型   
  40. document.execCommand('FontName',false,'標楷體');   //true或false都可以   
  41. //字型變粗   
  42. document.execCommand('Bold');   
  43. //變斜體   
  44. document.execCommand('Italic');   
  45. }   
  46. /*  
  47. *該function用來將選中的區塊加上不同的線條  
  48. */  
  49. function fn_change_selection()   
  50. {   
  51. //將選中的文字加底線   
  52. document.execCommand('Underline');   
  53. //在選中的文字上劃粗線   
  54. document.execCommand('StrikeThrough');   
  55. //將選中的部分文字變細   
  56. document.execCommand('SuperScript');   
  57. //將選中區塊的底線取消掉   
  58. document.execCommand('Underline');    
  59. }   
  60. /*  
  61.   *該function用來將選中的區塊排成不同的格式  
  62.   */  
  63. function fn_format()   
  64. {   
  65. //有序列排列   
  66. document.execCommand('InsertOrderedList');   
  67. //實心無序列排列   
  68. document.execCommand('InsertUnorderedList');   
  69. //空心無序列排列   
  70. document.execCommand('Indent');   
  71. }   
  72. /*  
  73. *該function用來將選中的區塊剪下或是刪除掉  
  74. */  
  75. function fn_CutOrDel()   
  76. {   
  77. //刪除選中的區塊   
  78. //document.execCommand('Delete');   
  79. //剪下選中的區塊   
  80. document.execCommand('Cut');   
  81. }   
  82. /*  
  83. *該function用來將選中的區塊重設為一個相應的物件  
  84. */  
  85. function fn_InsObj()   
  86. {   
  87. /*  
  88.   ******************************************  
  89.   * 以下指令都是為選中的區塊重設一個object;  
  90.   * 如沒有特殊說明,第二個參數true或false是一樣的;  
  91.   * 參數三表示為該object的id;  
  92.   * 可以用在javascript中通過其指定的id來控制它  
  93.   ******************************************  
  94. */  
  95. /*重設為一個button(InsertButton和InsertInputButtong一樣,  
  96. 只不前者是button,後者是input)*/  
  97. /*document.execCommand('InsertButton',false,"aa"); //true或false無效  
  98. document.all.aa.value="風舞九天";*/  
  99. //重設為一個fieldset   
  100. /*document.execCommand('InsertFieldSet',true,"aa");  
  101. document.all.aa.innerText="刀劍如夢";*/  
  102. //插入一個水平線   
  103. //document.execCommand('InsertHorizontalRule',true,"aa");   
  104. //插入一個iframe   
  105. //document.execCommand('InsertIFrame',true,"aa");   
  106. //插入一個InsertImage,設為true時需要圖片,false時不需圖片   
  107. //document.execCommand('InsertImage',false,"aa");   
  108. //插入一個checkbox   
  109. //document.execCommand('InsertInputCheckbox',true,"aa");   
  110. //插入一個file類型的object   
  111. //document.execCommand('InsertInputFileUpload',false,"aa");   
  112. //插入一個hidden   
  113. /*document.execCommand('InsertInputHidden',false,"aa");  
  114. alert(document.all.aa.id);*/  
  115. //插入一個InputImage   
  116. /*document.execCommand('InsertInputImage',false,"aa");  
  117. document.all.aa.src="F-a10.gif";*/  
  118. //插入一個Password   
  119. //document.execCommand('InsertInputPassword',true,"aa");   
  120. //插入一個Radio   
  121. //document.execCommand('InsertInputRadio',false,"aa");   
  122. //插入一個Reset   
  123. //document.execCommand('InsertInputReset',true,"aa");   
  124. //插入一個Submit   
  125. //document.execCommand('InsertInputSubmit',false,"aa");   
  126. //插入一個input text   
  127. //document.execCommand('InsertInputText',false,"aa");   
  128. //插入一個textarea   
  129. //document.execCommand('InsertTextArea',true,"aa");   
  130. //插入一個 select list box   
  131. //document.execCommand('InsertSelectListbox',false,"aa");   
  132. //插入一個single select   
  133. //document.execCommand('InsertSelectDropdown',true,"aa");   
  134. //插入一個line break(硬斷行符號??)   
  135. //document.execCommand('InsertParagraph');   
  136. //插入一個marquee   
  137. /*document.execCommand('InsertMarquee',true,"aa");  
  138. document.all.aa.innerText="bbbbb";*/  
  139. //用於取消選中的陰影部分   
  140. //document.execCommand('Unselect');   
  141. //選中頁面上的所有元素   
  142. //document.execCommand('SelectAll');   
  143. }   
  144. /*  
  145. *該function用來將頁面儲存為一個檔案  
  146. */  
  147. function fn_save()   
  148. {   
  149. //第二個參數為欲儲存的檔案名稱   
  150. document.execCommand('SaveAs','mycodes.txt');   
  151. //列印整個頁面   
  152. //document.execCommand('print');   
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.