Execcommand Instruction Set for JavaScript-http://www.yongfa365.com/Item/JavaScript-execCommand.html

Source: Internet
Author: User
  1. /*
  2. * This function executes the Copy command.
  3. */
  4. Function fn_doufucopy (){
  5. Edit. Select ();
  6. Document.exe ccommand ('copy ');
  7. }
  8. /*
  9. * This function executes the paste command.
  10. */
  11. Function fn_doufupaste (){
  12. TT. Focus ();
  13. Document.exe ccommand ('paste ');
  14. }
  15. /*
  16. * This function is used to create a hyperlink.
  17. */
  18. Function fn_creatlink ()
  19. {
  20. Document.exe ccommand ('createlink ', true, 'true'); // enter the URL in the pop-up dialog box.
  21. // Document.exe ccommand ('createlink ', false, 'HTTP: // www.51js.com ');
  22. }
  23. /*
  24. * This function is used to set the selected block as the specified background color.
  25. */
  26. Function fn_change_backcolor ()
  27. {
  28. Document.exe ccommand ('backcolor', true, '# ffbbdd'); // true or false
  29. }
  30. /*
  31. * This function is used to set the selected block as the specified foreground color, change the font size, font size, and font width of the selected block.
  32. */
  33. Function fn_change_forecolor ()
  34. {
  35. // Specify the foreground color
  36. Document.exe ccommand ('forecolor', false, '# bbddcc'); // true or false
  37. // Specify the background color
  38. Document.exe ccommand ('fontsize', false, 7); // true or false
  39. // The font must be the font supported by the system.
  40. Document.exe ccommand ('fontname', false, ''); // true or false
  41. // Font thickening
  42. Document.exe ccommand ('bold ');
  43. // Italics
  44. Document.exe ccommand ('italic ');
  45. }
  46. /*
  47. * This function is used to add different lines to the selected block.
  48. */
  49. Function fn_change_selection ()
  50. {
  51. // Underline the selected text
  52. Document.exe ccommand ('underline ');
  53. // Draw a rough line on the selected text
  54. Document.exe ccommand ('strikethangout ');
  55. // Refine the selected text
  56. Document.exe ccommand ('superscript ');
  57. // Remove the underline of the selected block
  58. Document.exe ccommand ('underline ');
  59. }
  60. /*
  61. * This function is used to arrange the selected blocks in different formats.
  62. */
  63. Function fn_format ()
  64. {
  65. // Sequential arrangement
  66. Document.exe ccommand ('insertorderedlist ');
  67. // Solid and non-sequential arrangement
  68. Document.exe ccommand ('insertunorderedlist ');
  69. // Empty sequence arrangement
  70. Document.exe ccommand ('indent ');
  71. }
  72. /*
  73. * This function is used to cut down or delete the selected block.
  74. */
  75. Function fn_cutordel ()
  76. {
  77. // Delete the selected block
  78. // Document.exe ccommand ('delete ');
  79. // Cut down the selected block
  80. Document.exe ccommand ('cut ');
  81. }
  82. /*
  83. * This function is used to reset the selected block to an object.
  84. */
  85. Function fn_insobj ()
  86. {
  87. /*
  88. **************************************** **
  89. * The following commands reset an object for the selected block;
  90. * Unless otherwise specified, the second parameter true or false is the same;
  91. * Parameter 3 indicates the ID of the object;
  92. * You can use the specified ID in JavaScript to control it.
  93. **************************************** **
  94. */
  95. /* Reset to a button (insertbutton and insertinputbuttong are the same,
  96. Only the former is the button, and the latter is the input )*/
  97. /* Document.exe ccommand ('insertbutton', false, "AA"); // The value true or false is invalid.
  98. Document. All. AA. value = "Wind dance nine days ";*/
  99. // Reset to a fieldset
  100. /* Document.exe ccommand ('insertfieldset', true, "AA ");
  101. Document. All. AA. innertext = "sword as a dream ";*/
  102. // Insert a horizontal line
  103. // Document.exe ccommand ('inserthorizontalrule', true, "AA ");
  104. // Insert an IFRAME
  105. // Document.exe ccommand ('insertiframework', true, "AA ");
  106. // Insert an insertimage. If it is set to true, images are required. If it is set to false, images are not required.
  107. // Document.exe ccommand ('insertimage', false, "AA ");
  108. // Insert a checkbox
  109. // Document.exe ccommand ('insertinputcheckbox', true, "AA ");
  110. // Insert a file-type object
  111. // Document.exe ccommand ('insertinputfileupload', false, "AA ");
  112. // Insert a hidden
  113. /* Document.exe ccommand ('insertinputhidden ', false, "AA ");
  114. Alert (document. All. AA. ID );*/
  115. // Insert an inputimage
  116. /* Document.exe ccommand ('insertinputimage', false, "AA ");
  117. Document. All. AA. src = "F-a10.gif ";*/
  118. // Insert a password
  119. // Document.exe ccommand ('insertinputpassword', true, "AA ");
  120. // Insert a radio
  121. // Document.exe ccommand ('insertinputradio ', false, "AA ");
  122. // Insert a reset
  123. // Document.exe ccommand ('insertinputreset', true, "AA ");
  124. // Insert a submit
  125. // Document.exe ccommand ('insertinputsubmit ', false, "AA ");
  126. // Insert an input text
  127. // Document.exe ccommand ('insertinputtext', false, "AA ");
  128. // Insert a textarea
  129. // Document.exe ccommand ('inserttextarea ', true, "AA ");
  130. // Insert a select list box
  131. // Document.exe ccommand ('insertselectlistbox', false, "AA ");
  132. // Insert a single SELECT statement
  133. // Document.exe ccommand ('insertselectdropdown', true, "AA ");
  134. // Insert a line break (hard press enter ??)
  135. // Document.exe ccommand ('insertparagraph ');
  136. // Insert a marquee
  137. /* Document.exe ccommand ('insert', true, "AA ");
  138. Document. All. AA. innertext = "bbbbb ";*/
  139. // Used to cancel the selected shadow part
  140. // Document.exe ccommand ('unselect ');
  141. // Select all elements on the page
  142. // Document.exe ccommand ('selectall ');
  143. }
  144. /*
  145. * This function is used to save the page as a file.
  146. */
  147. Function fn_save ()
  148. {
  149. // The second parameter is the name of the file to be saved.
  150. Document.execcommand('saveas', 'mycodes.txt ');
  151. // Print the entire page
  152. // Document.exe ccommand ('print ');
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.