Make Web online editor-Insert HTML tags _ experience Exchange

Source: Internet
Author: User
I used to think that the online editor of the web was nothing more than a replacement for the input and a quick way to insert HTML code, but when I did it I found that although the principle was the same, the implementation was not as rigid as I thought. Since I seldom do anything on the UI, I now know that there is a ExecCommand method in document to solve the problem of inserting HTML tags, which can insert the required HTML tags at the cursor location, and note that If you insert a tag within a restricted range, you need to get the focus first, for example:
A.focus ();
A.document.execcommand (' Insertbutton ', ' ', ' btn ');
The A object here is an IFrame object. The first parameter in ExecCommand is the command for the control that needs to be inserted, the 2nd is not yet known, and the 3rd is the ID name, where a id=btn button control is inserted, and if you want to add additional properties you just need to write it back, for example
A.document.execcommand (' Insertbutton ', ' ', ' btn class=btnclass color=red ');

A detailed list of the first parameters
2d-position allows an absolutely positioned object to be moved by dragging.
AbsolutePosition the Position property of the Set 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 the current selection is displayed in bold or not.
Browsemode is not currently supported.
Copy copies the currently selected area 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 be inserted for the current selection.
Cut copies the currently selected area to the Clipboard and deletes it.
Delete Deletes the currently 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 for the current selection.
ForeColor Sets or gets the foreground (text) color of the currently selected area.
Formatblock sets the current block formatting label.
Indent increases the indentation of the selected text.
INLINEDIRLTR is not currently supported.
INLINEDIRRTL is not currently supported.
Insertbutton overrides the current selection with a button control.
InsertFieldSet overwrites the current selection with a box.
Inserthorizontalrule overwrites the current selection with a horizontal line.
Insertiframe overwrites the current selection with an inline frame.
Insertimage overwrites the current selection with an image.
Insertinputbutton overrides the current selection with a button control.
Insertinputcheckbox overwrites the current selection with a check box control.
Insertinputfileupload overwrites the current selection with a file upload control.
Insertinputhidden inserts a hidden control that overrides the current selection.
Insertinputimage overwrites the current selection with an image control.
Insertinputpassword overwrites the current selection with a password control.
Insertinputradio overwrites the current selection with the radio button control.
Insertinputreset overrides the current selection with a reset control.
Insertinputsubmit overwrites the current selection with a Submit control.
Insertinputtext overwrites the current selection with a text control.
Insertmarquee overwrites the current selection with an empty caption.
Insertorderedlist Toggles whether the current selection is a numbered list or a regular formatting block.
InsertParagraph overwrites the currently selected area with a newline.
Insertselectdropdown overwrites the current selection with a drop-down box control.
Insertselectlistbox overwrites the current selection with a ListBox control.
Inserttextarea overwrites the current selection with the multiline text input control.
Insertunorderedlist Toggles whether the current selection is a bulleted list or a regular formatting block.
Italic Toggle the current selection italic display or not.
Justifycenter the current selection in the formatted block.
Justifyfull is not currently supported.
Justifyleft aligns the formatting blocks in the current selection to the left.
Justifynone is not currently supported.
Justifyright Right aligns the formatting blocks in the current selection.
Liveresize forces the MSHTML editor to continuously update the appearance of elements while zooming or moving, rather than just updating after the move or zoom is complete.
Multipleselection allows more than one site-selectable element to be selected at a time when the user holds down the shift or Ctrl key.
Open.
Outdent reduces the indentation of the formatting block where the selection is located.
OverWrite toggles the insertion and overwriting of text states.
Paste overwrites the current selection with the Clipboard contents.
Playimage is not currently supported.
Print opens the Printing dialog box so that the user 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 Select 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 toggles whether the underline of the current selection is displayed or not.
Undo undone.
Unlink removes all hyperlinks from the currently selected area.
Unselect clears the selected state of the current selection.

In addition, inserting characters at the point where the mouse is currently located can be done in the following ways:


ZDFZADFASFDASDFADSF
  • 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.