ExecCommand () commands in JavaScript and examples show __java

Source: Internet
Author: User

The ExecCommand method is to execute a command on the current document, currently selected or given a range. used when working with HTML data
The following format: Document.execcommand (scommand[, interactive, dynamic parameters]), where: Scommand is the instruction parameter ("2d-position" in the example below), the interactive argument if it is true, the dialog box will be displayed. If False, the dialog box is not displayed ("false" in the following example means that the dialog box is not displayed), and dynamic parameters are generally an available value or property value ("True" in the following example).

Document.execcommand ("2d-position", "false", "true");
The following is a list of instruction parameters and meanings 2d-position allows you to move an object that is absolutely positioned by dragging.
The position attribute of the AbsolutePosition setting element is "absolute" (absolute).
BackColor Sets or gets the background color of the currently selected area.
BLOCKDIRLTR is not currently supported.
BLOCKDIRRTL is not currently supported.
Bold toggles whether or not bold is displayed in the currently selected area.
Browsemode is not currently supported.
Copy copies the current selection to the Clipboard.
CreateBookMark creates a bookmark anchor or gets the name of the bookmark anchor for the current selection or insertion point.
Createlink inserts a hyperlink on the current selection, or displays a dialog box that allows the user to specify the URL of the hyperlink to insert for the current selection.
Cut copies the current selection to the Clipboard and deletes it.
Delete Deletes the current selected area.
DIRLTR is not currently supported.
DIRRTL is not currently supported.
EditMode is not currently supported.
FontName Sets or gets the font for the currently selected area.
FontSize Sets or gets the font size of the current selected area.
ForeColor Sets or gets the foreground (text) color of the currently selected area.
Formatblock sets the current block format label.
Indent increases the indentation of the selected text.
INLINEDIRLTR is not currently supported.
INLINEDIRRTL is not currently supported.
Insertbutton overwrites the current selection with a button control.
InsertFieldSet the current selected area with a box.
Inserthorizontalrule the current selected area with a horizontal line.
Insertiframe overwrites the current selection with an inline frame.
Insertimage overwrites the current selected area with an image.
Insertinputbutton overwrites the current selection with a button control.
Insertinputcheckbox overwrites the current selection with a check box control.
Insertinputfileupload overwrites the current selected area with a file upload control.
Insertinputhidden inserts a hidden control to overwrite the current selected area.
Insertinputimage overwrites the current selected area with an image control.
Insertinputpassword overwrites the current selection with a password control.
Insertinputradio overwrites the currently selected area with the radio buttons control.Insertinputreset overwrites the current selection with the reset control.
Insertinputsubmit overwrites the currently selected area with the Submit control.
Insertinputtext overwrites the current selected area with a text control.
Insertmarquee overwrites the current selection with blank captions.
Insertorderedlist Toggles whether the current selection is a numbered list or a regular format block.
The insertparagraph overwrites the current selection with a newline.
Insertselectdropdown the Drop-down box control to overwrite the current selection.
Insertselectlistbox overwrites the current selection with a list box control.
Inserttextarea overwrites the current selection with multiple lines of text input controls.
Insertunorderedlist Toggles whether the current selection is a bulleted list or a regular format block.
Italic Toggle the current selection italic display or not.
Justifycenter the current selection in the format block where it is placed.
Justifyfull is not currently supported.
Justifyleft aligns the formatting blocks of the current selection to the left.
Justifynone is not currently supported.
Justifyright aligns the formatting blocks of the current selection to the right.
Liveresize forces the MSHTML editor to continuously update the appearance of the element during scaling or moving, rather than updating it after the move or zoom is complete.
Multipleselection allows you to select more than one site optional element at a time when the user holds down the Shift or Ctrl key.
Open is not currently supported.
Outdent reduces the indentation of the formatted block where the selected area is located.
OverWrite toggles the insertion and overwrite of the text state.
Paste overwrites the current selected area with the Clipboard contents.
Playimage is not currently supported.
Print opens a printing dialog box so that users can print the current page.
Redo is not currently supported.
Refresh refreshes the current document.
Removeformat removes the formatted label from the current selection.
Removeparaformat is not currently supported.
SaveAs saves the current Web page as a file.
SelectAll selects the entire document.
SizeToControl is not currently supported.
SizeToControlHeight is not currently supported.
SizeToControlWidth is not currently supported.
Stop is not currently supported.
Stopimage is not currently supported.
Strikethrough is not currently supported. Subscript is not yet supportedHold.
Superscript is not currently supported.
Unbookmark removes all bookmarks from the current selection.
Underline toggle the underline displayed in the current selection.
Undo is not currently supported.
Unlink removes all hyperlinks from the current selection.
 Unselect clears the selected state of the current check area.

Document. ExecCommand () –html instance

<HTML> <HEAD> <title>javascript--execcommand Instruction set </TITLE> <script Langu

age= "JavaScript" > <!--* * This function performs the copy instruction */function fn_doufucopy () {edit.select ();

Document.execcommand (' Copy ');

* * * This function executes paste instruction/function fn_doufupaste () {tt.focus ();

Document.execcommand (' paste '); /* * This function is used to create a hyperlink/function Fn_creatlink () {document.execcommand (' Createlink ', true, ' true ');//Pop up a dialog box to enter U

RL//document.execcommand (' Createlink ', false, ' http://www.51js.com '); /* * This function is used to set the selected block to the specified background color/function Fn_change_backcolor () {Document.execcommand (' BackColor ', True, ' #FFbbDD //true or False can be}/* * This function is used to set the selected block to the specified foreground color, to change the font size of the selected block, to change the font, to make the font bold and oblique/function Fn_change_forecolor () {//Specify Foreground color Document.execcommand (' ForeColor ', false, ' #BBDDCC ');//true or false can//specify background color Document.execcommand (' fontsize ',   false,7); True or false can//font must be a system-supported font Document.execcommand (' FontName ', false, ' superscript italics '));

True or false can//font become thicker document.execcommand (' bold ');

Variable italic document.execcommand (' italic ');

/* * This function is used to add the selected block with a different line/function fn_change_selection () {///To underline the selected text Document.execcommand (' underline ');

Underline the selected text Document.execcommand (' strikethrough ');

Change the selected part of the text to Document.execcommand (' superscript '); 

The underline of the selected block is canceled off Document.execcommand (' underline ');

/* * This function is used to arrange the selected blocks into different formats/function Fn_format () {//Ordered Document.execcommand (' insertorderedlist ');

Solid unordered Array Document.execcommand (' insertunorderedlist ');

Hollow Sequence-free document.execcommand (' Indent ');

/* * This function is used to cut or remove the selected block/function Fn_cutordel () {//delete the selected block//document.execcommand (' delete ');

Cut the selected block Document.execcommand (' cuts '); /* * This function is used to reset the selected block to a corresponding object/function Fn_insobj () {/* ****************************************** * below

  instruction is to reset an object for the selected block;

  * If no special instructions, the second parameter true or false is the same;

  * Parameter three is represented by the ID of the object; * You can control it in JavaScript by its specified ID ********/* Reset to a button (Insertbutton and Insertinputbuttong, only the former is a button, the latter is input) * * Document.execcommand (' Insertbutton ', false, "AA"); True or false invalid Document.all.aa.value= "Wind dance Nine Days";//Reset to a fieldset/*document.execcommand (' InsertFieldSet ', True, "AA")

;

document.all.aa.innertext= "sword like Dream";///Insert a horizontal line//document.execcommand (' Inserthorizontalrule ', True, "AA");

Insert an IFRAME//document.execcommand (' Insertiframe ', True, "AA");

Insert a insertimage, set to True when the picture is required, false without the picture//document.execcommand (' Insertimage ', false, "AA");

Insert a CheckBox//document.execcommand (' Insertinputcheckbox ', True, "AA");

Inserts a file type of object//document.execcommand (' Insertinputfileupload ', false, "AA");

Insert a hidden/*document.execcommand (' Insertinputhidden ', false, "AA");

alert (document.all.aa.id); *///Insert a inputimage/*document.execcommand (' Insertinputimage ', false, "AA");

Document.all.aa.src= "f-a10.gif";//Insert a password//document.execcommand (' Insertinputpassword ', True, "AA"); Insert an RADio//document.execcommand (' Insertinputradio ', false, "AA");

Insert a Reset//document.execcommand (' Insertinputreset ', True, "AA");

Insert a Submit//document.execcommand (' Insertinputsubmit ', false, "AA");

Inserts an input text//document.execcommand (' Insertinputtext ', false, "AA");

Insert a textarea//document.execcommand (' Inserttextarea ', True, "AA");

Inserts a select list box//document.execcommand (' Insertselectlistbox ', false, "AA");

Inserts a single select Document.execcommand (' Insertselectdropdown ', True, "AA");

Insert a line break (hard return??)

Document.execcommand (' insertparagraph ');

Insert a marquee/*document.execcommand (' Insertmarquee ', True, "AA");

document.all.aa.innertext= "BBBBB";///used to deselect the shaded section//document.execcommand (' unselect ');

Select all elements on the page//document.execcommand (' SelectAll ');

/* * This function is used to save the page as a file/function Fn_save () {//The second parameter is the filename to be saved Document.execcommand (' SaveAs ', ' mycodes.txt ');

Print the entire page//document.execcommand (' print '); }--> </SCRIPT> 

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.