document.execCommand()编程

下面这些都是对选中内容的操作:

<input type=button value=剪切 onclick=document.execCommand('Cut')>
<input type=button value=拷贝 onclick=document.execCommand('Copy')>
<input type=button value=粘贴 onclick=document.execCommand('Paste')>
<input type=button value=撤消 onclick=document.execCommand('Undo')>
<input type=button value=重做 onclick=document.execCommand('Redo') id=button2 name=button2>
<input>
<input type=button value=删除 onclick=document.execCommand('Delete')>
<input type=button value=黑体 onclick=document.execCommand('Bold')>
<input type=button value=斜体 onclick=document.execCommand('Italic')>
<input type=button value=下划线 onclick=document.execCommand('Underline')>
<input type=button value=停止 onclick=document.execCommand('stop')>
<input type=button value=保存 onclick=document.execCommand('SaveAs')>
<input type=button value=另存为 onclick=document.execCommand('Saveas',false,'c:\\test.htm')>
<input type=button value=字体 onclick=document.execCommand('FontName',false,fn)>
<input type=button value=字体大小 onclick=document.execCommand('FontSize',false,fs)>
<input type=button value=刷新 onclick=document.execCommand('refresh',false,0)>  

UnBookmark 从当前选中区中删除全部书签。 
Underline 切换当前选中区的下划线显示与否。 
Undo 撤消。 
Unlink 从当前选中区中删除全部超级链接。 
Unselect 清除当前选中区的选中状态。

SelectAll 选中整个文档。 

JustifyCenter 将当前选中区在所在格式化块置中。 
JustifyLeft 将当前选中区所在格式化块左对齐。 
JustifyRight 将当前选中区所在格式化块右对齐。

转自:http://blog.sina.com.cn/s/blog_4efce4d10100cimp.html

原文地址:https://www.cnblogs.com/bicabo/p/1438362.html