天天看点

execCommand全集

?

?砌蛹copy?貧ttp://longtianyu1.blog.163.com/blog/static/998196520092155745419/

JavaScript銝剔??execCommand隞?蝏?

?

execCommand?寞??舀?扯?銝?銝芸笆敶?????獢??敶??????拇????蝏??箄???渡???賭誘??憭???Html?唳?格?嗅虜?? 憒?銝??澆?嚗?document.execCommand(sCommand[,鈭支??孵?, ?冽?????財) 嚗??嗡葉嚗?sCommand銝箸??隞文???堆?憒?銝?靘?銝剔??"2D-Position"嚗?嚗?鈭支??孵????啣????眩rue??霂?撠??曄內撖寡?獢?嚗?憒???銝榻alse??霂?嚗???銝??曄內撖寡?獢?嚗?銝?靘?銝剔??"false"?唾”蝷箔??曄內撖寡?獢?嚗?嚗??冽?????唬??砌蛹銝??舐?典?潭??撅??批?潘?憒?銝?靘?銝剔??"true"嚗???

document.execCommand("2D-Position","false","true");

銝??W???箇???舀??隞文???啣????銋?

?

2D-Position ??霈賊??餈????喟宏?函?撖孵?雿???撖寡情??

AbsolutePosition 霈曉???蝝??? position 撅??找蛹??absolute??(蝏?撖???

BackColor 霈曄蔭???瑕??敶?????銝剖?箇?????舫??脯??

BlockDirLTR ?桀??撠??芣?舀????

BlockDirRTL ?桀??撠??芣?舀????

Bold ???W?????銝剖?箇??蝎?雿??曄內銝??艾??

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 ???W?????銝剖?箸?舐??瑕??銵刻??臬虜閫??澆???????

InsertParagraph ?冽?Z?閬???敶?????銝剖?箝??

InsertSelectDropdown ?其???獢??找辣閬???敶?????銝剖?箝??

InsertSelectListbox ?典??銵冽??找辣閬???敶?????銝剖?箝??

InsertTextArea ?典?銵????祈??交?找辣閬???敶?????銝剖?箝??

InsertUnorderedList ???W?????銝剖?箸?舫★?桃泵?瑕??銵刻??臬虜閫??澆???????

Italic ???W?????銝剖?箸??雿??曄內銝??艾??

JustifyCenter 撠?敶?????銝剖?箏?冽???冽?澆?????蝵桐葉??

JustifyFull ?桀??撠??芣?舀????

JustifyLeft 撠?敶?????銝剖?箸???冽?澆?????撌血笆朣???

JustifyNone ?桀??撠??芣?舀????

JustifyRight 撠?敶?????銝剖?箸???冽?澆??????喳笆朣???

LiveResize 餈思蝙 MSHTML 蝻?颲??典?函憬?暹??蝘餃?刻?蝔?銝剜??蝏剜?湔?啣??蝝?憭?閫?嚗???銝??臬?芸?函宏?冽??蝻拇?曉??????湔?啜??

MultipleSelection ??霈詨??冽?瑟??雿? Shift ?? Ctrl ?格?嗡?甈⊿??銝剖?鈭?銝?銝芰??孵?舫????蝝???

Open ?桀??撠??芣?舀????

Outdent ??撠???銝剖?箸???冽?澆???????蝻抵???

OverWrite ???X???祉?嗆???????亙??閬?????

Paste ?典?芾斐?踹??摰寡???敶?????銝剖?箝??

PlayImage ?桀??撠??芣?舀????

Print ??撘????啣笆霂?獢?隞乩噶?冽?瑕?臭誑???啣???憿萸??

Redo ?桀??撠??芣?舀????

Refresh ?瑟?啣?????獢???

RemoveFormat 隞?敶?????銝剖?箔葉???斗?澆?????蝑整??

RemoveParaFormat ?桀??撠??芣?舀????

SaveAs 撠?敶??? Web 憿菟?V?摮?銝箸??隞嗚??

SelectAll ??銝剜?港葵??獢???

SizeToControl ?桀??撠??芣?舀????

SizeToControlHeight ?桀??撠??芣?舀????

SizeToControlWidth ?桀??撠??芣?舀????

Stop ?桀??撠??芣?舀????

StopImage ?桀??撠??芣?舀????

StrikeThrough ?桀??撠??芣?舀????

Subs cript ?桀??撠??芣?舀????

Supers cript ?桀??撠??芣?舀????

UnBookmark 隞?敶?????銝剖?箔葉???文?券?其髡蝑整??

Underline ???W?????銝剖?箇??銝???蝥踵?曄內銝??艾??

Undo ?桀??撠??芣?舀????

Unlink 隞?敶?????銝剖?箔葉???文?券?刻?蝥折?暹?乓??

Unselect 皜??文?????銝剖?箇????銝剔?嗆????

<HTML>

<HEAD>

<SCRIPT LANGUAGE="JScript">

function fn_doufucopy() {

edit.select();

document.execCommand('Copy');

}

function fn_doufupaste() {

tt.focus();

document.execCommand('paste');

}

__>

</SCRIPT>

</head>

<body>

<input id=edit value=??靘?><br>

<button 怷nclick=fn_doufucopy()>Copy</button>

<button 怷nclick=fn_doufupaste()>paste</button><br>

<textarea id=tt rows=10 cols=50></textarea>

</body>

</html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=big5">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>execCommand?渡??</title>

<script language=javascript>

?? function fn_creatlink()

?? {

??? document.execCommand('CreateLink',true,'true');//撘孵?箔?銝芸笆霂?獢?颲??冊RL

??? //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()

{

??

??

??

?? //??霈曆蛹銝?銝沽ieldset

??

?? //???乩?銝芣偌撟喟瑪

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

?? //???乩?銝波frame

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

?? //???乩?銝杷nsertImage,霈曆蛹true?園??閬??曄??,false?嗡????曄??

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

?? //???乩?銝泌heckbox

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

?? //???乩?銝沽ile蝐餃????object

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

?? //???乩?銝沼idden

??

?? //???乩?銝杷nputImage

??

?? //???乩?銝枉assword

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

?? //???乩?銝析adio

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

?? //???乩?銝析eset

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

?? //???乩?銝杵ubmit

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

?? //???乩?銝波nput text

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

?? //???乩?銝泱extarea

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

?? //???乩?銝?select list box

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

?? //???乩?銝泅ingle select

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

?? //???乩?銝泓ine break(蝖砍??頧??)

?? //document.execCommand('InsertParagraph');

?? //???乩?銝沸arquee

??

?? //?其???瘨???銝剔???游蔣?典??

?? //document.execCommand('Unselect');

?? //??銝剝△?V?????????蝝?

?? //document.execCommand('SelectAll');

}

function fn_save()

{

?? //蝚砌?銝芸???唬蛹甈脖?摮?????隞嗅??

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

?? //???唳?港葵憿菟?? ?? //document.execCommand('print');

}

</script>

</head>

<body>

瘚格?????????????,雿??舀?餃?臬?瑕??????<br>

憭抵?交????憭拐漲??,鈭粹?湔迤???舀異獢?.<br>

?賣?芣??,憭芣?抒??,?港?蝑?銝??啗?勗??嗉??<br>

<input type=button value="??撱慢reateLink" 怷nclick=fn_creatlink()><br>

<input type=button value="?孵????摮????航?? 怷nclick=fn_change_backcolor()><br>

<input type=button value="?孵????摮????航?? 怷nclick=fn_change_forecolor()><br>

<input type=button value="蝏???摮???蝥踵?? 怷nclick=fn_change_selection()><br>

<input type=button value="?孵????摮???????" 怷nclick=fn_format()><br>

<input type=button value="???斗???芯???銝剔???典??" 怷nclick=fn_CutOrDel()><br>

<input type=button value="???令bject" 怷nclick=fn_InsObj()><br>

<input type=button value="靽?摮??????唳??隞? 怷nclick=fn_save()><br>

<input type=button value="瘚?霂?Refresh撅??? 怷nclick="document.execCommand('Refresh')">

</body>

</html>

?桅?????孵??舀?瘣颱?銝?lt;iframe>餈??亦?颲??嗆??嚗??賭誘憒?銝?

IframeNamer.document.designMode="On"

摮?雿?--摰?雿???暺?雿???璆瑚?蝑?

execCommand("fontname","",摮?雿?)

摮???-摮??瑕之撠?

execCommand("fontsize","",摮???

????

execCommand("Bold")

??雿?

execCommand("Italic")

銝???蝥?

execCommand("Underline")

???斤瑪

execCommand("StrikeThrough")

銝???

execCommand("SuperScript")

銝???

execCommand("SubScript")

??摨?????--?啣?摨???

execCommand("InsertOrderedList")

??摨?????--???孵???

execCommand("InsertUnorderedList")

????蝻抵?

execCommand("Outdent")

????蝻抵?

execCommand("Indent")

撅?撌?

execCommand("JustifyLeft")

撅???

execCommand("JustifyRight")

撅?銝?

execCommand("JustifyCenter")

?芸??

execCommand("Cut")

?瑁?

execCommand("Copy")

蝎?韐?

execCommand("Paste")

閬???

execCommand("Overwrite")

??瘨???雿?--IE5.0隞亙???臭誑??????瘨?

execCommand("Undo")

??憭???雿?

execCommand("Redo")

霈曄蔭?暹??-?交??隞乩???瘜?嚗??沉E5.0???砌葉隡?瞈?瘣颱?銝芸??撱箇?????臭誑摰???颲??仿?暹?亦?????踝???銝?餈??臭誑???和AILTO??FTP蝑???蝘??暹?亦掩??嚗?瘥?颲??嫣噶

execCommand("CreateLink")

?沉E4.0銝哨?瘝⊥????撱粹?暹?亥??亦??????隞亙停??閬??其誑銝??孵?撋??仿?暹??

execCommand("CreateLink","",TURL)

???亙?曄??--?曹?IE銝剖??亦???舐??找辣?舫??撖寞?砍?啗?皞???嚗???隞亙?園?霈斤???曄??韏?皞??亥?芣?砍?堆???隞亙?箔?WEB??摰寧??蝻?颲???憟質?芸楛??颲??交?嚗??嗅???典?銝??賭誘摰??啜??

execCommand("InsertImage","",ImgURL)

摮?雿?憸???

execCommand("ForeColor","",CColor)

?

继续阅读