Copy codeThe Code is as follows: D-Position allows you to move an absolute Position object by dragging it.
AbsolutePosition: Set the position attribute of the element to "absolute" (absolute ).
Set BackColor or obtain the background color of the selected area.
BlockDirLTR is not currently supported.
BlockDirRTL is not currently supported.
Bold switches whether the selected area is in Bold or not.
BrowseMode is not currently supported.
Copy Copies the selected area to the clipboard.
CreateBookmark: Create a bookmarks anchor to obtain the name of the bookmarks anchor of the selected area or insert point.
CreateLink inserts a hyperlink in the selected area or displays a dialog box that allows you to specify the URL of the hyperlink to be inserted for the selected area.
Cut: copy the selected area to the clipboard and delete it.
Delete deletes the selected area.
DirLTR is not currently supported.
DirRTL is not currently supported.
EditMode is not supported currently.
FontName: set or obtain the font of the selected area.
FontSize: set or obtain the font size of the selected area.
Set or obtain the foreground (text) color of the selected area.
FormatBlock sets the formatting label of the current block.
Indent increases the indentation of selected text.
InlineDirLTR is not currently supported.
InlineDirRTL is not currently supported.
InsertButton overwrites the selected area with a button control.
InsertFieldset overwrites the selected area with a box.
InsertHorizontalRule overwrites the selected area with a horizontal line.
InsertIFrame overwrites the selected area with an embedded frame.
InsertImage overwrites the selected area with an image.
InsertInputButton overwrites the selected area with a button control.
InsertInputCheckbox overwrites the selected area with the check box control.
InsertInputFileUpload overwrites the selected area with the file upload control.
InsertInputHidden inserts a hidden control to overwrite the selected area.
InsertInputImage overwrites the selected area with an image control.
InsertInputPassword overwrites the selected zone with a password control.
InsertInputRadio overwrites the selected area with a single-choice button control.
InsertInputReset overwrites the selected area with the Reset Control.
InsertInputSubmit overwrites the selected area with the submit control.
InsertInputText overwrites the selected area with a text control.
InsertMarquee overwrites the selected area with empty subtitles.
InsertOrderedList: select the number list or regular formatting block for the selected area.
InsertParagraph overwrites the selected area with a line break.
InsertSelectDropdown overwrites the selected area with the drop-down box control.
InsertSelectListbox overwrites the selected area with the list box control.
InsertTextArea overwrites the selected area with the multi-line text input control.
InsertUnorderedList switches whether the selected area is a project symbol list or a regular formatting block.
Italic switch to whether the selected area is displayed in Italic or not.
JustifyCenter: place the selected area in the formatting block.
JustifyFull is not currently supported.
JustifyLeft: Align the formatting block of the selected area to the left.
JustifyNone is not currently supported.
JustifyRight: Right-aligned the formatting block of the selected area.
LiveResize forces the MSHTML editor to continually update the appearance of Elements During Scaling or movement, instead of updating the elements only after moving or scaling.
MultipleSelection allows you to select more than one optional site element at a time when you press Shift or Ctrl.
Open.
Outdent reduces the indentation of the formatting block where the selected area is located.
OverWrite switches the insert and OverWrite of the text status.
Paste overwrites the selected area with the clipboard content.
PlayImage is not currently supported.
Print opens the Print dialog box so that you can Print the current page.
Redo.
Refresh the current document.
RemoveFormat deletes the format tag from the selected area.
RemoveParaFormat is not supported currently.
SaveAs saves the current Web page as a file.
SelectAll: select the entire document.
Currently, SizeToControl is not supported.
Currently, SizeToControlHeight is not supported.
Currently, SizeToControlWidth is not supported.
Stop.
StopImage is not currently supported.
StrikeThrough is not currently supported.
Subscript is not currently supported.
Superscript is not currently supported.
UnBookmark deletes all bookmarks from the selected area.
Underline switches whether the Underline of the selected area is displayed.
Undo.
Unlink deletes all hyperlinks from the selected area.
Unselect clears the selected status of the selected area.
<HTML>
<HEAD>
<TITLE> JavaScript -- execCommand instruction set </TITLE>
<Script language = "javascript">
<! --
/*
* This function executes the copy command.
*/
Function fn_doufucopy (){
Edit. select ();
Document.exe cCommand ('copy ');
}
/*
* This function executes the paste command.
*/
Function fn_doufupaste (){
Tt. focus ();
Document.exe cCommand ('paste ');
}
/*
* This function is used to create a hyperlink.
*/
Function fn_creatlink ()
{
Document.exe cCommand ('createlink ', true, 'true'); // enter the URL in the pop-up dialog box.
// Document.exe cCommand ('createlink ', false, 'HTTP: // www.51js.com ');
}
/*
* This function is used to set the selected block as the specified background color.
*/
Function fn_change_backcolor ()
{
Document.exe cCommand ('backcolor', true, '# ffbbdd'); // true or false
}
/*
* 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.
*/
Function fn_change_forecolor ()
{
// Specify the foreground color
Document.exe cCommand ('forecolor', false, '# bbddcc'); // true or false
// Specify the background color
Document.exe cCommand ('fontsize', false, 7); // true or false
// The font must be the font supported by the system.
Document.exe cCommand ('fontname', false, ''); // true or false
// Font thickening
Document.exe cCommand ('bold ');
// Italics
Document.exe cCommand ('italic ');
}
/*
* This function is used to add different lines to the selected block.
*/
Function fn_change_selection ()
{
// Underline the selected text
Document.exe cCommand ('underline ');
// Draw a rough line on the selected text
Document.exe cCommand ('strikethangout ');
// Refine the selected text
Document.exe cCommand ('superscript ');
// Remove the underline of the selected block
Document.exe cCommand ('underline ');
}
/*
* This function is used to arrange the selected blocks in different formats.
*/
Function fn_format ()
{
// Sequential arrangement
Document.exe cCommand ('insertorderedlist ');
// Solid and non-sequential arrangement
Document.exe cCommand ('insertunorderedlist ');
// Empty sequence arrangement
Document.exe cCommand ('indent ');
}
/*
* This function is used to cut down or delete the selected block.
*/
Function fn_CutOrDel ()
{
// Delete the selected block
// Document.exe cCommand ('delete ');
// Cut down the selected block
Document.exe cCommand ('cut ');
}
/*
* This function is used to reset the selected block to an object.
*/
Function fn_InsObj ()
{
/*
**************************************** **
* The following commands reset an object for the selected block;
* Unless otherwise specified, the second parameter true or false is the same;
* Parameter 3 indicates the id of the object;
* You can use the specified id in javascript to control it.
**************************************** **
*/
/* Reset to a button (InsertButton and InsertInputButtong are the same,
Only the former is the button, and the latter is the input )*/
/* Document.exe cCommand ('insertbutton', false, "aa"); // The value true or false is invalid.
Document. all. aa. value = "Wind dance nine days ";*/
// Reset to a fieldset
/* Document.exe cCommand ('insertfieldset', true, "aa ");
Document. all. aa. innerText = "sword as a dream ";*/
// Insert a horizontal line
// Document.exe cCommand ('inserthorizontalrule', true, "aa ");
// Insert an iframe
// Document.exe cCommand ('insertiframework', true, "aa ");
// Insert an InsertImage. If it is set to true, images are required. If it is set to false, images are not required.
// Document.exe cCommand ('insertimage', false, "aa ");
// Insert a checkbox
// Document.exe cCommand ('insertinputcheckbox', true, "aa ");
// Insert a file-type object
// Document.exe cCommand ('insertinputfileupload', false, "aa ");
// Insert a hidden
/* Document.exe cCommand ('insertinputhidden ', false, "aa ");
Alert (document. all. aa. id );*/
// Insert an InputImage
/* Document.exe cCommand ('insertinputimage', false, "aa ");
Document. all. aa. src = "F-a10.gif ";*/
// Insert a Password
// Document.exe cCommand ('insertinputpassword', true, "aa ");
// Insert a Radio
// Document.exe cCommand ('insertinputradio ', false, "aa ");
// Insert a Reset
// Document.exe cCommand ('insertinputreset', true, "aa ");
// Insert a Submit
// Document.exe cCommand ('insertinputsubmit ', false, "aa ");
// Insert an input text
// Document.exe cCommand ('insertinputtext', false, "aa ");
// Insert a textarea
// Document.exe cCommand ('inserttextarea ', true, "aa ");
// Insert a select list box
// Document.exe cCommand ('insertselectlistbox', false, "aa ");
// Insert a single select statement
Document.exe cCommand ('insertselectdroplow', true, "aa ");
// Insert a line break (hard press enter ??)
// Document.exe cCommand ('insertparagraph ');
// Insert a marquee
/* Document.exe cCommand ('insert', true, "aa ");
Document. all. aa. innerText = "bbbbb ";*/
// Used to cancel the selected shadow part
// Document.exe cCommand ('unselect ');
// Select all elements on the page
// Document.exe cCommand ('selectall ');
}
/*
* This function is used to save the page as a file.
*/
Function fn_save ()
{
// The second parameter is the name of the file to be saved.
Document.execcommand('saveas', 'mycodes.txt ');
// Print the entire page
// Document.exe cCommand ('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 = "10" cols = "50" NAME = "tt"> </textarea>
<Hr>
<Br>
The ups and downs converge and change again, but it can always make a comeback. <br>
If the days are old, the daily routine is vicissitudes of life. <br>
I was so persistent that I could not wait for the flowers to bloom. <br>
<Br>
Please select above letters, then click following buttons: <br>
<Hr>
<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 lines to text" onclick = "fn_change_selection ()" ID = "Button6" NAME = "Button6"> <br>
<Input type = "button" value = "Change text Arrangement" onclick = "fn_format ()" ID = "Button7" NAME = "Button7"> <br>
<Input type = "button" value = "delete or cut the selected part" 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 the file" onclick = "fn_save ()" ID = "Button10" NAME = "Button10"> <br>
<Input type = "button" value = "test Refresh attributes" onclick = "document.exe cCommand ('refresh')" ID = "Button11"
NAME = "Button11">
</Body>
</HTML>
The normal method is to activate an <iframe> to enter the editing status. The command is as follows:
IframeNamer.doc ument. designMode = "On"
Font:,, and
ExecCommand ("fontname", "", font)
Font size-font size
ExecCommand ("fontsize", "", font size)
Increase
ExecCommand ("Bold ")
Italics
ExecCommand ("Italic ")
Underline
ExecCommand ("Underline ")
Strikethrough
ExecCommand ("StrikeThrough ")
Superscript
ExecCommand ("SuperScript ")
Subscript
ExecCommand ("SubScript ")
Ordered Arrangement-Number
ExecCommand ("InsertOrderedList ")
Unordered arrangement-dot serial number
ExecCommand ("InsertUnorderedList ")
Forward indent
ExecCommand ("Outdent ")
Backward indent
ExecCommand ("Indent ")
Left
ExecCommand ("JustifyLeft ")
Right
ExecCommand ("JustifyRight ")
Center
ExecCommand ("JustifyCenter ")
Cut
ExecCommand ("Cut ")
Copy
ExecCommand ("Copy ")
Paste
ExecCommand ("Paste ")
Overwrite
ExecCommand ("Overwrite ")
Cancel operation-you can cancel the operation without limit after IE5.0
ExecCommand ("Undo ")
Repeated operation
ExecCommand ("Redo ")
Set link-if you write the following code, a built-in window will be activated in IE5.0 to complete the link input function, and various link types such as MAILTO and FTP can be selected for ease of use
ExecCommand ("CreateLink ")
In IE4.0, there is no built-in link input window, so you need to embed the link in the following way:
ExecCommand ("CreateLink", "", TURL)
Insert an image-since the programmable controls embedded in IE are for local resources, the default image resources are from the local, so it is best to edit the WEB content in the input box by yourself, run the following command.
ExecCommand ("InsertImage", "", ImgURL)
Font color
ExecCommand ("ForeColor", "", CColor)