天天看點

document.execCommand()接口文檔

2D-Position 允許通過拖曳移動絕對定位的對象。

AbsolutePosition 設定元素的 position 屬性為“absolute”(絕對)。

BackColor 設定或擷取目前選中區的背景顔色。

BlockDirLTR 目前尚未支援。

BlockDirRTL 目前尚未支援。

Bold 切換目前選中區的粗體顯示與否。

BrowseMode 目前尚未支援。

Copy 将目前選中區複制到剪貼闆。

CreateBookmark 建立一個書簽錨或擷取目前選中區或插入點的書簽錨的名稱。

CreateLink 在目前選中區上插入超級連結,或顯示一個對話框允許使用者指定要為目前選中區插入的超級連結的 URL。

Cut 将目前選中區複制到剪貼闆并删除之。

Delete 删除目前選中區。

DirLTR 目前尚未支援。

DirRTL 目前尚未支援。

EditMode 目前尚未支援。

FontName 設定或擷取目前選中區的字型。

FontSize 設定或擷取目前選中區的字型大小。

ForeColor 設定或擷取目前選中區的前景(文本)顔色。

FormatBlock 設定目前塊格式化标簽。

Indent 增加選中文本的縮進。

InlineDirLTR 目前尚未支援。

InlineDirRTL 目前尚未支援。

InsertButton 用按鈕控件覆寫目前選中區。

InsertFieldset 用方框覆寫目前選中區。

InsertHorizontalRule 用水準線覆寫目前選中區。

InsertIFrame 用内嵌架構覆寫目前選中區。

InsertImage 用圖像覆寫目前選中區。

InsertInputButton 用按鈕控件覆寫目前選中區。

InsertInputCheckbox 用複選框控件覆寫目前選中區。

InsertInputFileUpload 用檔案上載控件覆寫目前選中區。

InsertInputHidden 插入隐藏控件覆寫目前選中區。

InsertInputImage 用圖像控件覆寫目前選中區。

InsertInputPassword 用密碼控件覆寫目前選中區。

InsertInputRadio 用單選鈕控件覆寫目前選中區。

InsertInputReset 用重置控件覆寫目前選中區。

InsertInputSubmit 用送出控件覆寫目前選中區。

InsertInputText 用文本控件覆寫目前選中區。

InsertMarquee 用空字幕覆寫目前選中區。

InsertOrderedList 切換目前選中區是編号清單還是正常格式化塊。

InsertParagraph 用換行覆寫目前選中區。

InsertSelectDropdown 用下拉框控件覆寫目前選中區。

InsertSelectListbox 用清單框控件覆寫目前選中區。

InsertTextArea 用多行文本輸入控件覆寫目前選中區。

InsertUnorderedList 切換目前選中區是項目符号清單還是正常格式化塊。

Italic 切換目前選中區斜體顯示與否。

JustifyCenter 将目前選中區在所在格式化塊置中。

JustifyFull 目前尚未支援。

JustifyLeft 将目前選中區所在格式化塊左對齊。

JustifyNone 目前尚未支援。

JustifyRight 将目前選中區所在格式化塊右對齊。

LiveResize 迫使 MSHTML 編輯器在縮放或移動過程中持續更新元素外觀,而不是隻在移動或縮放完成後更新。

MultipleSelection 允許當使用者按住 Shift 或 Ctrl 鍵時一次選中多于一個站點可選元素。

Open 打開。

Outdent 減少選中區所在格式化塊的縮進。

OverWrite 切換文本狀态的插入和覆寫。

Paste 用剪貼闆内容覆寫目前選中區。

PlayImage 目前尚未支援。

Print 打開列印對話框以便使用者可以列印目前頁。

Redo 重做。

Refresh 重新整理目前文檔。

RemoveFormat 從目前選中區中删除格式化标簽。

RemoveParaFormat 目前尚未支援。

SaveAs 将目前 Web 頁面儲存為檔案。

SelectAll 選中整個文檔。

SizeToControl 目前尚未支援。

SizeToControlHeight 目前尚未支援。

SizeToControlWidth 目前尚未支援。

Stop 停止。

StopImage 目前尚未支援。

StrikeThrough 目前尚未支援。

Subscript 目前尚未支援。

Superscript 目前尚未支援。

UnBookmark 從目前選中區中删除全部書簽。

Underline 切換目前選中區的下劃線顯示與否。

Undo 撤消。

Unlink 從目前選中區中删除全部超級連結。

Unselect 清除目前選中區的選中狀态。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

<

HTML

>

<

HEAD

>

<

TITLE

>JavaScript--execCommand指令集</

TITLE

>

<

SCRIPT

LANGUAGE="javascript">

<!--

function fn_doufucopy(){

edit.select();

document.execCommand('Copy');

}

function fn_doufupaste() {

tt.focus();

document.execCommand('paste');

}

function fn_creatlink()

{

document.execCommand('CreateLink',true,'true');//彈出一個對話框輸入URL

//document.execCommand('CreateLink',false,'http://www.51js.com');

}

function fn_change_backcolor()

{

document.execCommand('BackColor',true,'#FFbbDD');//true或false都可以

}

function fn_change_forecolor()

{

//指定前景色

document.execCommand('ForeColor',false,'#BBDDCC');//true或false都可以

//指定背景色

document.execCommand('FontSize',false,7);      //true或false都可以

//字型必須是系統支援的字型

document.execCommand('FontName',false,'标楷體');      //true或false都可以

//字型變粗

document.execCommand('Bold');

//變斜體

document.execCommand('Italic');

}

function fn_change_selection()

{

//将選中的文字加下劃線

document.execCommand('Underline');

//在選中的文字上劃粗線

document.execCommand('StrikeThrough');

//将選中的部分文字變細

document.execCommand('SuperScript');

//将選中區塊的下劃線取消掉

document.execCommand('Underline');

}

function fn_format()

{

//有序列排列

document.execCommand('InsertOrderedList');

//實心無序列排列

document.execCommand('InsertUnorderedList');

//空心無序列排列

document.execCommand('Indent');

}

function fn_CutOrDel()

{

//删除選中的區塊

//document.execCommand('Delete');

//剪下選中的區塊

document.execCommand('Cut');

}

function fn_InsObj()

{

//重設為一個fieldset

//插入一個水準線

//document.execCommand('InsertHorizontalRule',true,"aa");

//插入一個iframe

//document.execCommand('InsertIFrame',true,"aa");

//插入一個InsertImage,設為true時需要圖檔,false時不需圖檔

//document.execCommand('InsertImage',false,"aa");

//插入一個checkbox

//document.execCommand('InsertInputCheckbox',true,"aa");

//插入一個file類型的object

//document.execCommand('InsertInputFileUpload',false,"aa");

//插入一個hidden

//插入一個InputImage

//插入一個Password

//document.execCommand('InsertInputPassword',true,"aa");

//插入一個Radio

//document.execCommand('InsertInputRadio',false,"aa");

//插入一個Reset

//document.execCommand('InsertInputReset',true,"aa");

//插入一個Submit

//document.execCommand('InsertInputSubmit',false,"aa");

//插入一個input text

//document.execCommand('InsertInputText',false,"aa");

//插入一個textarea

//document.execCommand('InsertTextArea',true,"aa");

//插入一個 select list box

//document.execCommand('InsertSelectListbox',false,"aa");

//插入一個single select

document.execCommand('InsertSelectDropdown',true,"aa");

//插入一個line break(硬回車??)

//document.execCommand('InsertParagraph');

//插入一個marquee

//用于取消選中的陰影部分

//document.execCommand('Unselect');

//選中頁面上的所有元素

//document.execCommand('SelectAll');

}

function fn_save()

{

//第二個參數為欲儲存的檔案名

document.execCommand('SaveAs','mycodes.txt');

//列印整個頁面

//document.execCommand('print');

}

-->

</

SCRIPT

>

</

HEAD

>

<

body

>

<

input

id="edit" value="範例" 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

>

浮沉聚散變化又再,但是總可卷土重來.<

br

>

天若有情天亦老,人間正道是滄桑.<

br

>

都怪我,太執着,卻也等不到花開葉落.<

br

>

<

br

>

Please select above letters, then click following buttons:<

br

>

<

hr

>

<

input

type="button" value="建立CreateLink" onclick="fn_creatlink()" ID="Button3" NAME="Button3"><

br

>

<

input

type="button" value="改變文字背景色" onclick="fn_change_backcolor()" ID="Button4" NAME="Button4"><

br

>

<

input

type="button" value="改變文字前景色" onclick="fn_change_forecolor()" ID="Button5" NAME="Button5"><

br

>

<

input

type="button" value="給文字加線條" onclick="fn_change_selection()" ID="Button6" NAME="Button6"><

br

>

<

input

type="button" value="改變文字的排列" onclick="fn_format()" ID="Button7" NAME="Button7"><

br

>

<

input

type="button" value="删除或剪下選中的部分" onclick="fn_CutOrDel()" ID="Button8" NAME="Button8"><

br

>

<

input

type="button" value="插入Object" onclick="fn_InsObj()" ID="Button9" NAME="Button9"><

br

>

<

input

type="button" value="儲存或列印檔案" onclick="fn_save()" ID="Button10" NAME="Button10"><

br

>

<

input

type="button" value="測試Refresh屬性" onclick="document.execCommand('Refresh')" ID="Button11"       NAME="Button11">

</

body

>

</

HTML

>