Document.execcommand () parameters in JavaScript and examples of usage

Source: Internet
Author: User
Tags file upload numeric

Processing HTML data is often used in the following format: Document.execcommand (scommand[, interactive, dynamic parameters]), where: Scommand is the instruction parameter ("2d-position" in the example below), Interaction parameter If True, the dialog box is displayed, and 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).


The first thing to say is that under the Firefox support is not good.

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 opens.
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 Redo.
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 stops.
Stopimage is not currently supported.
Strikethrough is not currently supported.
Subscript is not currently supported.
Superscript is not currently supported.
Unbookmark removes all bookmarks from the current selection.
Underline toggle the underline displayed in the current selection.
Undo undone.
Unlink removes all hyperlinks from the current selection.
Unselect clears the selected state of the current check area.

Example 1:

isNaN is the test is a numeric type, restricted input can only be numeric values such as: 1981.121, allow a maximum of one decimal point

<input type= "text" name= "text" onkeyup= "if (isNaN (value)) ExecCommand (' Undo ')"/>

Example 2:

<input Type=button value= Shearing Onclick=document.execcommand (' cut ') >
<input Type=button value= copy onclick=document.execcommand (' Copy ') >
<input Type=button value= paste onclick=document.execcommand (' Paste ') >
<input Type=button value= undo Onclick=document.execcommand (' Undo ') >
<input Type=button value= Redo Onclick=document.execcommand (' Redo ') Id=button2 name=button2>
<input>
<input Type=button value= Delete onclick=document.execcommand (' delete ') >
<input Type=button value= Bold Onclick=document.execcommand (' bold ') >
<input Type=button value= Italic onclick=document.execcommand (' italic ') >
<input Type=button value= underline onclick=document.execcommand (' underline ') >
<input Type=button value= Stop Onclick=document.execcommand (' Stop ') >
<input Type=button value= Save Onclick=document.execcommand (' SaveAs ') >
<input Type=button value= Save As Onclick=document.execcommand (' Saveas ', false, ' c:test.htm ') >
<input Type=button value= Font onclick=document.execcommand (' FontName ', FALSE,FN) >
<input Type=button value= Font size onclick=document.execcommand (' fontsize ', false,fs) >
<input Type=button value= Refresh Onclick=document.execcommand (' Refresh ', false,0) >

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.