手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>Java技术>列表

Textarea标签封装为Web在线编辑器

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

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("Undo");
vEditorDiv.focus();
}
function defineRedo()
{
vEditorDiv.focus();
document.execCommand("Redo");
vEditorDiv.focus();
}
function defineBold()
{
vEditorDiv.focus();
document.execCommand("Bold");
vEditorDiv.focus();
}
function defineItalic()
{
vEditorDiv.focus();
document.execCommand("Italic");
vEditorDiv.focus();
}
function defineUnderLine()
{
vEditorDiv.focus();
document.execCommand("UnderLine");
vEditorDiv.focus();
}
function defineTable()
{
window.confirm("Table");
}
function defineJustifyLeft()
{
vEditorDiv.focus();
document.execCommand("JustifyLeft");
vEditorDiv.focus();
}
function defineJustifyCenter()
{
vEditorDiv.focus();
document.execCommand("JustifyCenter");
vEditorDiv.focus();
}
function defineJustifyRight()
{
vEditorDiv.focus();
document.execCommand("JustifyRight");
vEditorDiv.focus();
}
function defineInsertOrderedList()
{
vEditorDiv.focus();
document.execCommand("InsertOrderedList");
vEditorDiv.focus();
}
function defineInsertUnorderedList()
{
vEditorDiv.focus();
document.execCommand("InsertUnorderedList");
vEditorDiv.focus();
}
function defineOutdent()
{
vEditorDiv.focus();
document.execCommand("Outdent");
vEditorDiv.focus();
}
function defineIndent()
{
vEditorDiv.focus();
document.execCommand("Indent");
vEditorDiv.focus();
}
function defineColor()
{
chooseColor();
}
function defineFontSize()
{
chooseFontSize();
}
function defineFontFamily()
{
chooseFontFamily();
}
function defineInsertImage()
{
vEditorDiv.focus();
document.execCommand("InsertImage");
vEditorDiv.focus();
}
function defineCreateLink()
{
vEditorDiv.focus();
document.execCommand("CreateLink");
vEditorDiv.focus();
}
function defineInsertHorizontalRule()
{
vEditorDiv.focus();
document.execCommand("InsertHorizontalRule");
vEditorDiv.focus();
}
function definePrint()
{
vEditorDiv.focus();
document.execCommand("Print");
vEditorDiv.focus();
}
function definePreview()
{
window.confirm("Preview");
}
//辅助函数
//颜色滴管
function chooseColor()
{
var strReturnColor=vColorObject.ChooseColorDlg("FFFFFF");
strReturnColor=strReturnColor.toString(16);
if(strReturnColor.length<6)
{
var strTempString="000000".substring(0,6-strReturnColor.length);
strReturnColor=strTempString.concat(strReturnColor);
}
vEditorDiv.focus();
document.execCommand("ForeColor",false,strReturnColor);

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!