Cument.execcommand () Use deep understanding of the basics

Source: Internet
Author: User
Tags file upload
Copy Code code as follows:

D-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.
<HTML>
<HEAD>
<title>javascript--execcommand instruction Set </TITLE>
<script language= "JavaScript" >
<!--
/*
* This function performs the copy instruction
*/
function Fn_doufucopy () {
Edit.select ();
Document.execcommand (' Copy ');
}
/*
* This function executes the 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 ');/popup dialog box enter URL
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, change the font size of the selected block, change the font, and make the font bold and oblique.
*/
function Fn_change_forecolor ()
{
Specify foreground color
Document.execcommand (' ForeColor ', false, ' #BBDDCC ');//true or false can be
Specify background color
Document.execcommand (' fontsize ', false,7); True or false can be
Font must be a system-supported font
Document.execcommand (' FontName ', false, ' superscript italics '); True or false can be
Font size becomes thicker
Document.execcommand (' Bold ');
Variable Italic body
Document.execcommand (' italic ');
}
/*
* This function is used to add a different line to the selected block
*/
function Fn_change_selection ()
{
Underline the selected text
Document.execcommand (' underline ');
Underline the selected text
Document.execcommand (' strikethrough ');
To make the selected part of the text thinner
Document.execcommand (' superscript ');
Remove the underline of the selected block
Document.execcommand (' underline ');
}
/*
* This function is used to arrange the selected blocks into different formats
*/
function Fn_format ()
{
Have sequence arrangement
Document.execcommand (' insertorderedlist ');
Solid No-sequence arrangement
Document.execcommand (' insertunorderedlist ');
Hollow No-sequence arrangement
Document.execcommand (' Indent ');
}
/*
* This function is used to cut or delete the selected block
*/
function Fn_cutordel ()
{
Delete the selected block
Document.execcommand (' Delete ');
Cut down the selected block
Document.execcommand (' cut ');
}
/*
* This function is used to reset the selected block to a corresponding object
*/
function Fn_insobj ()
{
/*
******************************************
* The following instructions are 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 is not valid
Document.all.aa.value= "Wind dance nine Days";
Reset to a FieldSet
/*document.execcommand (' InsertFieldSet ', True, "AA");
Document.all.aa.innertext= "The sword is like a 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 you need a picture, false without a 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 a 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");
Insert a SELECT list box
Document.execcommand (' Insertselectlistbox ', false, "AA");
Insert 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";
Shaded section for unchecked selection
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 file name you want to save
Document.execcommand (' SaveAs ', ' mycodes.txt ');
Print the entire page
Document.execcommand (' print ');
}
-->
</SCRIPT>
</HEAD>
<body>
<input id= "edit" value= "Example" name= "edit" ><br>
<button onclick= "fn_doufucopy ()" id= "Button1" >Copy</button> <button onclick= "Fn_doufupaste ()" Id= " Button2 ">
Paste</button><br>
<textarea id= "tt" rows= "cols=" Name= "tt" ></textarea>
<br>
Ups and downs change again, but can always be a comeback .<br>
If the sky is also old, the earth is the vicissitudes of life .<br>
All blame me, too persistent, but also can not wait to blossom leaves fall .<br>
<br>
Please select above letters, then click following buttons:<br>
<input type= "button" value= "Create Createlink" onclick= "Fn_creatlink ()" id= "Button3" name= "Button3" ><br>
<input type= "button" value= "Change text background color" onclick= "Fn_change_backcolor ()" id= "Button4" name= "Button4" ><br>
<input type= "button" value= "Change text foreground color" onclick= "Fn_change_forecolor ()" id= "Button5" name= "Button5" ><br>
<input type= "button" value= "Add line to Text" onclick= "fn_change_selection ()" id= "Button6" name= "Button6" ><br>
<input type= "button" value= "Change the arrangement of text" onclick= "Fn_format ()" id= "Button7" name= "Button7" ><br>
<input type= "button" value= "Delete or Trim selected section" onclick= "Fn_cutordel ()" id= "Button8" name= "Button8" ><br>
<input type= "button" value= "Insert Object" onclick= "Fn_insobj ()" id= "Button9" name= "Button9" ><br>
<input type= "button" value= "Save or print File" onclick= "Fn_save ()" id= "Button10" name= "Button10" ><br>
<input type= "button" value= "Test Refresh Property" onclick= "Document.execcommand (' Refresh ')" id= "Button11"
Name= "Button11" >
</body>
</HTML>
The normal way is to activate a <iframe> into edit State, command as follows
Iframenamer.document.designmode= "On"
FONT--XXFarEastFont-Arial, blackbody, italics, etc.
ExecCommand ("FontName", "", font)
Font Size--sizes
ExecCommand ("FontSize", "", Font size)
Increase
ExecCommand ("Bold")
Italic body
ExecCommand ("italic")
Underline
ExecCommand ("Underline")
Delete Line
ExecCommand ("Strikethrough")
Superscript
ExecCommand ("superscript")
Subscript
ExecCommand ("Subscript")
Ordered arrangement--numeric serial number
ExecCommand ("Insertorderedlist")
Unordered arrangement--Dot ordinal
ExecCommand ("Insertunorderedlist")
Indent forward
ExecCommand ("Outdent")
Indent backwards
ExecCommand ("Indent")
Ju Zuo
ExecCommand ("Justifyleft")
Ju Right
ExecCommand ("Justifyright")
Center
ExecCommand ("Justifycenter")
Shear
ExecCommand ("Cut")
Copy
ExecCommand ("Copy")
Paste
ExecCommand ("Paste")
Covered
ExecCommand ("Overwrite")
Cancel Operation--ie5.0 can be canceled indefinitely
ExecCommand ("Undo")
Repeat action
ExecCommand ("Redo")
Set the link--if the following wording, in the IE5.0 version will activate a built-in window, you can complete the function of the input link, but also can choose Mailto, FTP and other types of links, more convenient
ExecCommand ("Createlink")
In IE4.0, there is no built-in link input window, so you need to embed the link in the following ways
ExecCommand ("Createlink", "" ", Turl)
Insert a picture-because the embedded editable controls in IE are for local resources, the default picture resources are local, so web content editors are best to make their own input boxes and then implement them with the following command.
ExecCommand ("Insertimage", "" ", Imgurl)
Font Color
ExecCommand ("ForeColor", "" ", Ccolor)

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.