Textarea标签封装为Web在线编辑器
Editor.htm
<textarea style="behavior:url('Editor.htc');"></textarea>
Editor.htc
<public:attach event=oncontentready onevent=initEditor()>
<script>
//对象
var vColorObject=null;
var vFontObject=null;
var vFontFamilyDiv=null;
var vFontSizeDiv=null;
var vFileObject=null;var vConsoleDiv=null;
var vEditorDiv=null;//按钮提示文本
var strButtonTitleArray=new Array("新建","打开","保存","剪切","复制","粘贴","取消","恢复","粗体","斜体","下划","表格","向左","居中","向右","编号","符号","缩进","缩出","字色","字号","字体","图像","链接","水平","打印","预览");
//按钮静态文本
var strButtonValueArray=new Array("新建","打开","保存","剪切","复制","粘贴","取消","恢复","粗体","斜体","下划","表格","向左","居中","向右","编号","符号","缩进","缩出","字色","字号","字体","图像","链接","水平","打印","预览");
//按钮接口程序
var strButtonDefineFunctionArray=new Array("defineNew()",
"defineOpen()",
"defineSave()",
"defineCut()",
"defineCopy()",
"definePaste()",
"defineUndo()",
"defineRedo()",
"defineBold()",
"defineItalic()",
"defineUnderLine()",
"defineTable()",
"defineJustifyLeft()",
"defineJustifyCenter()",
"defineJustifyRight()",
"defineInsertOrderedList()",
"defineInsertUnorderedList()",
"defineOutdent()",
"defineIndent()",
"defineColor()",
"defineFontSize()",
"defineFontFamily()",
"defineInsertImage()",
"defineCreateLink()",
"defineInsertHorizontalRule()",
"definePrint()",
"definePreview()");
//按钮图标
var strButtonDefineIconArray=new Array("","","","","","","","","","","","","","","","","","","","","","","","","","","");
//按钮响应库
function defineNew()
{
vEditorDiv.innerHTML="";
}
function defineOpen()
{
openFileDlg();
}
function defineSave()
{
element.value=vEditorDiv.innerHTML;
}
function defineCut()
{
vEditorDiv.focus();
document.execCommand("Cut");
vEditorDiv.focus();
}
function defineCopy()
{
vEditorDiv.focus();
document.execCommand("Copy");
vEditorDiv.focus();
}
function definePaste()
{
vEditorDiv.focus();
document.execCommand("Paste");
vEditorDiv.focus();
}
function defineUndo()
{
vEditorDiv.focus();
document.execCommand("Und
补充:网页制作,设计基础