登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> 程序员学前班[不再更新,只读] >> 主题: [html编辑器]execCommand 在firefox下面的问题及解决     [回主站]     [分站链接]
标题
[html编辑器]execCommand 在firefox下面的问题及解决
clq
浏览(0) + 2009-05-07 13:22:41 发表 编辑

关键字:

[html编辑器]execCommand 在firefox下面的问题及解决

问题是这样的
--------------------------------------------------

execCommand 在firefox下面的问题

本人在做一个博客,在添加文章的时候用到了一个编辑器,里面有一个这样的功能,就是图片上传以后可以点击插入到编辑器里面,在IE下面是显示的绝对路径,在firefox下面却是相对的路径,插入代码是
function insertHtml(html) {
var oRTE = getFrameNode(sRTE);
if(window.Event){
oRTE.document.execCommand('insertHTML',false, html);
} else {
oRTE.focus();
var oRng = oRTE.document.selection.createRange();
oRng.pasteHTML(html);
oRng.collapse(false);
oRng.select();
}
}
我测试了下,是这里执行插入的,在IE下面是没有问题,但是怎么在firefox下面就变成了相对的了,如果是网上的地址,那么是没有问题,要是本机上传的图片,使用这个就不对了,不知道改怎么修改
测试地址:
www.iamsi.com/gzbang/?action=login
用户名:hanson
密码:password
登陆进去在信息中心选择一个栏目进行添加,可以看到一个相关图片上传,从本地上传一个图片,然后点击插入内容到编辑,可以分别用IE和firefox测试,就会得到不同的结果,怎么能够达到统一呢?
小弟在这里先谢谢大家了,真的很急啊!

clq
2009-5-7 13:25:14 发表 编辑

解决办法是提交前先处理过.

//保存内容到隐藏文本框
ETSOOEditor._SaveContent=function(strName,numType){
var objField;
if(strName!=null)objField=this.Fields[strName];
else{
objField=ETSOOEditor.ActiveField;
numType=1;
}
if(objField&&objField.FrameWindow.document.body){
if(objField.TextArea.style.display=="none"){
var strContent=objField.FrameWindow.document.body.innerHTML;
if(ETSOOEditor.Browser>100)strContent=this.GetRelativePath(strContent);
objField.TextArea.value=strContent;
}
else if(numType==1)objField.FrameWindow.document.body.innerHTML=objField.TextArea.value;
}
}

clq
2009-5-7 13:25:49 发表 编辑

//取得网站根路径
ETSOOEditor.GetBasePath=function(){
var strBase=document.domain;
var numPort=document.location.port;
if(numPort!="")strBase+=':'+numPort;
return strBase;
}
//取得相对路径
ETSOOEditor.GetRelativePath=function(strPath){
var strBase=this.GetBasePath();
strPath=strPath.replace(new RegExp("http://"+strBase,"gi"),"");
return strPath;
}

clq
2009-5-7 13:28:06 发表 编辑

完整代码在

http://read.pudn.com/downloads61/sourcecode/java/210021/turbo_cwcshop/administrator/news/ETSOOEditor.js__.htm

不过不全,仅供参考.

--------------------------------------------------
/*
亿速编辑器由青岛亿速思维网络科技有限公司开发,版权所有,未经许可,严禁用于商业目的或作为其他产品的任何部分发布。
EOEditor by Qingdao ETSOO Network-Tech Co., Ltd. This script may not be used or distributed without license.
Version 4.0.0, http://www.etsoo.com
*/
//定义编辑器类
function ETSOOEditor(){}
//预定义ETSOOPreloadImage - 设置为true将预先加载图标
if(typeof(ETSOOPreloadImage)=="undefined")ETSOOPreloadImage=false;
ETSOOEditor.PreloadImage=ETSOOPreloadImage;
//预定义ETSOOActiveStatus - 允许实时按钮状态
if(typeof(ETSOOActiveStatus)=="undefined")ETSOOActiveStatus="auto";
var ETSOOEditor_Start=new Date().valueOf();
ETSOOEditor.ActiveStatus=ETSOOActiveStatus;
//获取脚本文件路径
function _EEGetPath(){
var arrScripts=document.getElementsByTagName("script");
var numLen=arrScripts.length;
var regEditor=/(.*)ETSOOEditor\.js/gi;
for(var numI=0;numI100)strLanguage=window.navigator.userLanguage;
else strLanguage=window.navigator.language;
if(strLanguage==null)strLanguage="en";
}
strLanguage=strLanguage.toLowerCase();
if(arrLanguages[strLanguage]==null)
{
strLanguage=strLanguage.split("-")[0];
if(arrLanguages[strLanguage]==null)strLanguage="en";
}
return strLanguage;
}

/* 定义编辑器全局属性和方法 */
//浏览器版本
function _EEGetBrowser(){
var numVersion=0,strApp=navigator.appVersion;
if(window.navigator.language==null){
var regApp=/ MSIE (.*);/gi;
if(regApp.test(strApp))numVersion=100+parseFloat(RegExp.$1);
}else numVersion=parseFloat(strApp);
return numVersion;
}
ETSOOEditor.Browser=_EEGetBrowser();
//全局execCommand关键字
if(ETSOOEditor.Browser<100){
CMD_ABSOLUTEPOS = "absoluteposition";
CMD_BOLD = "bold";
CMD_COPY = "copy";
CMD_CUT = "cut";
CMD_DELETE = "Delete";
CMD_FIND = "find";
CMD_FONT = "fontname";
CMD_GETBACKCOLOR = "backcolor";
CMD_GETFONTNAME = "fontname";
CMD_GETFONTSIZE = "fontsize";
CMD_GETFORECOLOR = "forecolor";
CMD_HYPERLINK = "createlink";
CMD_ANCHORLINK = "createbookmark";
CMD_IMAGE = "insertimage";
CMD_INDENT = "indent";
CMD_HR = "inserthorizontalrule";
CMD_ITALIC = "italic";
CMD_CENTER = "justifycenter";
CMD_LEFT = "justifyleft";
CMD_RIGHT = "justifyright";
CMD_FULL = "justifyfull";
CMD_ORDERLIST = "insertorderedlist";
CMD_OUTDENT = "outdent";
CMD_PASTE = "paste";
CMD_REDO = "redo";
CMD_REMOVEFORMAT = "removeformat";
CMD_SELECTALL = "selectall";
CMD_BGCOLOR = "backcolor";
CMD_SETBLOCKFMT = "formatblock";
CMD_FONTSET = "fontname";
CMD_FONTSIZE = "fontsize";
CMD_FORECOLOR = "forecolor";
CMD_STRIKETHROUGH = "strikethrough";
CMD_SUBSCRIPT = "subscript";
CMD_SUPERSCRIPT = "superscript";
CMD_UNDERLINE = "underline";
CMD_UNDO = "undo";
CMD_UNLINK = "unlink";
CMD_UNANCHOR = "unBookmark";
CMD_UNORDERLIST = "insertunorderedlist";

// User Interface
UI_DEFAULT = false;
UI_YES = true;
UI_NO = false;
}else{
CMD_ABSOLUTEPOS = "AbsolutePosition";
CMD_BOLD = "Bold";
CMD_COPY = "Copy";
CMD_CUT = "Cut";
CMD_DELETE = "Delete";
CMD_FIND = "Find";
CMD_FONT = "FontName";
CMD_GETBACKCOLOR = "BackColor";
CMD_GETFONTNAME = "FontName";
CMD_GETFONTSIZE = "FontSize";
CMD_GETFORECOLOR = "ForeColor";
CMD_HYPERLINK = "CreateLink";
CMD_ANCHORLINK = "CreateBookmark";
CMD_IMAGE = "InsertImage";
CMD_INDENT = "Indent";
CMD_HR = "InsertHorizontalRule";
CMD_ITALIC = "Italic";
CMD_CENTER = "JustifyCenter";
CMD_LEFT = "JustifyLeft";
CMD_RIGHT = "JustifyRight";
CMD_FULL = "JustifyFull";
CMD_ORDERLIST = "InsertOrderedList";
CMD_OUTDENT = "Outdent";
CMD_PASTE = "Paste";
CMD_REDO = "Redo";
CMD_REMOVEFORMAT = "RemoveFormat";
CMD_SELECTALL = "SelectAll";
CMD_BGCOLOR = "BackColor";
CMD_SETBLOCKFMT = "FormatBlock";
CMD_FONTSET = "FontName";
CMD_FONTSIZE = "FontSize";
CMD_FORECOLOR = "ForeColor";
CMD_STRIKETHROUGH = "StrikeThrough";
CMD_SUBSCRIPT = "SubScript";
CMD_SUPERSCRIPT = "SuperScript";
CMD_UNDERLINE = "Underline";
CMD_UNDO = "Undo";
CMD_UNLINK = "Unlink";
CMD_UNANCHOR = "UnBookmark";
CMD_UNORDERLIST = "InsertUnorderedList";

// User Interface
UI_DEFAULT = false;
UI_YES = true;
UI_NO = false;
}
//编辑器公用属性和方法
ETSOOEditor.AutoClearWord=ETSOOEditor.Browser<105.5?false:true;
ETSOOEditor.XMLDom=null;
ETSOOEditor.ActiveField=null;
ETSOOEditor.ActiveTarget=null;
ETSOOEditor.MenuBar=null;
ETSOOEditor.Fields=[];
ETSOOEditor.ReadyState=0;
ETSOOEditor.Version="4.0.0";
ETSOOEditor.SubMenu=[];
//取得网站根路径
ETSOOEditor.GetBasePath=function(){
var strBase=document.domain;
var numPort=document.location.port;
if(numPort!="")strBase+=':'+numPort;
return strBase;
}
//取得相对路径
ETSOOEditor.GetRelativePath=function(strPath){
var strBase=this.GetBasePath();
strPath=strPath.replace(new RegExp("http://"+strBase,"gi"),"");
return strPath;
}
var _BasePath=_EEGetPath();
_BasePath=_BasePath.replace(/\/\//gi,"\/");
ETSOOEditor.Path=_BasePath;
//字符变量,可以使用静态方法从而减小计算
ETSOOEditor.Langs=[];
//预载图片
ETSOOEditor.Inco={
NEW: "new.gif",OPEN: "open.gif",SAVE: "save.gif",FIND: "search.gif",CUT: "cut.gif",CUTDISABLED: "cutdisabled.gif",COPY: "copy.gif",COPYDISABLED: "copydisabled.gif",PASTE: "paste.gif",PASTEDISABLED: "pastedisabled",
PASTETEXT: "pastetext.gif",PASTEWORD: "pasteword.gif",DELETE: "delete.gif",DELETEDISABLED: "deletedisabled.gif",UNDO: "undo.gif",UNDODISABLED: "undodisabled.gif",REDO: "redo.gif",REDODISABLED: "redodisabled.gif",EMOTION: "emotion.gif",FLASH: "flash.gif",MEDIA: "media.gif",
MARQUEE: "marquee.gif",SPECIAL: "special.gif",IMAGELINK: "imagelink.gif",IMAGE: "image.gif",LAYER: "layer.gif",TABLE: "table.gif",INSERTROW: "table/insertrow.gif",INSERTCOL: "table/insertcol.gif",DELETEROW: "table/deleterow.gif",DELETECOL: "table/deletecol.gif",
SPLITCELL: "table/splitcell.gif",MERGECELL: "table/mergecell.gif",CELLPROPERTY: "table/cellproperty.gif",TABLEPROPERTY: "table/property.gif",FORM: "form.gif",FORMPROPERTY: "form/property.gif",FORMTEXT: "form/text.gif",FORMTEXTAREA: "form/textarea.gif",FORMFILE: "form/upload.gif",FORMCHECKBOX: "form/checkbox.gif",
FORMRADIO: "form/radio.gif",FORMFIELDSET: "form/fieldset.gif",FORMSELECT: "form/select.gif",FORMBUTTON: "form/button.gif",FORMIMAGE: "form/image.gif",FORMLABEL: "form/label.gif",HR: "hr.gif",LINK: "link.gif",LINKDISABLED: "linkdisabled.gif",EMAILLINK: "emaillink.gif",
ANCHOR: "anchor.gif",TAB: "tab.gif",PAINT: "paint/paint.gif",ART: "paint/art.gif",NORMALPROPERTY: "properties.gif",CONTROLPROPERTY: "controlproperty.gif",CSSPROPERTY: "cssproperty.gif",FULLSCREEN: "fullscreen.gif",HELP: "help.gif",ABOUT: "about.gif",
BOLD: "bold.gif",ITALIC: "italic.gif",UNDERLINE: "underline.gif",STRIKETHROUGH: "strikethrough.gif",REMOVEFORMAT: "removeformat.gif",LEFT: "justifyleft.gif",RIGHT: "justifyright.gif",CENTER: "justifycenter.gif",FULL: "justifyfull.gif",FORECOLOR: "forecolor.gif",
BGCOLOR: "backcolor.gif",ORDERLIST: "number.gif",UNORDERLIST: "unnumber.gif",INDENT: "indent.gif",OUTDENT: "outdent.gif",SUPERSCRIPT: "superscript.gif",SUPERSCRIPTDISABLED: "superscriptdisabled.gif",SUBSCRIPT: "subscript.gif",SUBSCRIPTDISABLED: "subscriptdisabled.gif",ABSOLUTEPOS: "abspos.gif",
ABSOLUTEPOSDISABLED: "absposdisabled.gif",UPLEVEL: "forward.gif",UPLEVELDISABLED: "forwarddisabled.gif",DOWNLEVEL: "backward.gif",DOWNLEVELDISABLED: "backwarddisabled.gif",FIRSTLEVEL: "first.gif",LASTLEVEL: "last.gif",DESIGN: "ViewDesign.gif",CODE: "ViewCode.gif",PREVIEW: "ViewPreview.gif",
INCREASE: "increase.gif",DECREASE: "decrease.gif",BLANK: "blank.gif",MORE: "more.gif", MOREDISABLED: "moredisabled.gif", CALENDAR: "calendar.gif",TIME: "time.gif", FORMULA: "formula.gif", UNLINK: "unlink.gif", ANCHORLINK: "anchorlink.gif", SELECTALL: "selectall.gif", EOEDITOR: "eoeditor.gif",
INSERTFILE: "file.gif", CLEARART: "delete.gif"
};
if(ETSOOEditor.PreloadImage)_preLoadImage();
//预载图片函数
function _preLoadImage(){
for(strItem in ETSOOEditor.Inco){
var strImage=ETSOOEditor.Inco[strItem];
var objImage=new Image();
objImage.src=_BasePath+"Images/"+strImage;
ETSOOEditor.Inco[strItem]=objImage;
}
};
//取得图片地址
ETSOOEditor.GetImgSrc=function(strName){
var strSrc;
with(this){
if(PreloadImage)strSrc=Inco[strName].src;
else strSrc=Path+"Images/"+Inco[strName];
}
return strSrc;
}
//默认字体
ETSOOEditor.BaseFonts=["Arial","Arial Black","Arial Narrow","Brush ScripMT","Century Gothic","Comic Sans MS","Courier","Courier New","MS Sans Serif","Script","System","Times New Roman","Verdana","Wide Latin","Wingdings","Wingdings 2","Wingdings 3"];
//补充字体
ETSOOEditor.AddFonts=[];
//是否已经预定义语言
var _BaseLanguage;
if(typeof(ETSOOBaseLanguage)=="undefined")_BaseLanguage=_EEGetLanguage();
else _BaseLanguage=ETSOOBaseLanguage;
ETSOOEditor.BaseLanguage=_BaseLanguage;
//生成一般图片事件
ETSOOEditor._GetImgStr=function(strPath,strBgColor,numWidth,numHeight,strName,strLang,strAdd){
var strImgSrc="blank.gif";
if(!this.PreloadImage){
var strIndex=strName;
if(strIndex.substring(0,2)=="EE")strIndex=strIndex.substr(2);
strImgSrc=this.Inco[strIndex.toUpperCase()];
}
var strImg=' ['+strLang+'] 0){
if(numPos<=numLen-1)blnValid=true;
}else{
if(numPos>=0)blnValid=true;
}
if(blnValid){
this.Position=numPos;
if(objField.TextArea.style.display=="none")objField.FrameWindow.document.body.innerHTML=this.Data[this.Position];
else objField.TextArea.value=this.Data[this.Position];
this.SetCursor();

ETSOOEditor._SetRedoUndo(numLen,numPos);
}
}
this.SetCursor=function(){
var objRange=this.Field.FrameWindow.document.body.createTextRange();
var strBM=this.BookMark[this.Position];
if(strBM!="[object]"&&strBM!=null){
if(objRange.moveToBookmark(strBM)){
objRange.collapse(false);
objRange.select();
}
}
}
}
//设置撤销重做图片按钮
ETSOOEditor._SetRedoUndo=function(numLen,numPos){
var numType=-1;
if(numLen>1&&numPos>0)numType=0;
ETSOOEditor._SetButton("Undo",numType);
var numType=-1;
if(numPos0)objStyle[0].disabled=blnDisabled;
}
//点击
ETSOOEditor.MouseClick=function(objE,_Add,objEvent){
if(objE.className=="Disabled"||(this.ReadyState==0&&_Add==null))return;
var objActive=this.ActiveField;
if(objActive==null)return;
var numBrowser=this.Browser;
var strId=objE.id;
if(objActive.Mode=="Preview"&&strId!="ToolDiv")return;
var objDoc=objActive.FrameWindow.document;
var strPath=this.Path;
switch(strId){
case "ToolDiv":
var strName=objE.getAttribute("name");
var strTarget=objE.getAttribute("Target");
var objFrame=document.getElementById("ETSOOEditorFrame_"+strTarget);
var objFrameWin=objActive.FrameWindow;
var objTextArea=objFrame.previousSibling;
var numHeight=parseInt(objTextArea.style.height);
switch(strName){
case "Design":
case "Code":
case "Preview":
var objField=this.Fields[strTarget];
var strBaseMode=objField.Mode;
if(_Add==null||_Add==true){
if(strBaseMode==strName)return;
this._FrameOnBlur();
if(strName=="Code"){
var numWidth=objFrame.clientWidth;
objFrame.style.display="none";
with(objTextArea.style){
display="block";
width=numWidth;
}
}else{
objTextArea.style.display="none";
objFrame.style.display="block";
if(strName=="Design"){
this._SetStyle(objFrameWin,false);
this._SetMode(objField.FrameWindow.document,"on");
}
else{
this._SetMode(objField.FrameWindow.document,"off");
this._SetStyle(objFrameWin,true);
}
}
var arrToolDivs=objField.Div.getElementsByTagName("div");
var numLen=arrToolDivs.length;
for(var numI=0;numI=200)numHeight-=100;
objTextArea.style.height=numHeight+"px";
objFrame.style.height=numHeight+"px";
break;
}
break;
case "EEMore":
var numLeft,numTop;
if(this.Browser<100){
var arrPos=ETSOOGetPos(objE);
numLeft=arrPos[0]-22;
numTop=arrPos[1]+objE.clientHeight+2;
}else{
numLeft=objEvent.clientX-objEvent.offsetX+document.body.scrollLeft-23;
numTop=objEvent.clientY+objE.clientHeight-objEvent.offsetY+document.body.scrollTop+1;
}
var strTarget=objE.getAttribute("target");
var numHeight=0,strContent='';
if(strTarget!="EEForeColor"&&strTarget!="EEBgColor"){
var strSubMenuTarget=objE.getAttribute("menutarget");
var objTarget=this.GetObj(strTarget);
var arrSubMenu=this.SubMenu[strSubMenuTarget];
if(strTarget==strSubMenuTarget)arrSubMenu=new Array(strTarget.substr(2),objTarget.title).concat(arrSubMenu);
else arrSubMenu=new Array(strSubMenuTarget.substr(2),objTarget.getAttribute("basetitle")).concat(arrSubMenu);
var arrMenus=this.GetSubMenu(arrSubMenu,strTarget);
strContent=arrMenus[0];
numHeight=arrMenus[1]*24+arrMenus[2]*6+4;
}
var objPopup=new ETSOOPopup(null,null,numHeight,numLeft,numTop,31,22);
objPopup.BgColor=objActive.BgColor;
objPopup.Skin=strPath+"Skins/"+objActive.Skin+"/Popup.css";
objPopup.Content=strContent;
objPopup.SourceObject=objE;
if(strContent==''){
var objNext=objE.previousSibling;
objPopup.Path=strPath;
objPopup.DefaultColor=objNext.style.backgroundColor;
objPopup.DoFunction="ETSOOEditor.SetColor";
objPopup.SourceId=strTarget;
objPopup.ShowColorPallette(this.OtherLangs[1],this.OtherLangs[2]);
}
else objPopup.Show();
break;
case "EENew":
if(confirm(this.OtherLangs[0])){
this.ActiveField.Reset();
}
break;
case "EEOpen":
break;
case "EEFind":
this.InsertObj("FIND");
break;
case "EESave":
break;
case "EEPasteText":
if(window.clipboardData){
strText=window.clipboardData.getData("Text");
if(strText==null)strText="";
this.InsertHTML(strText);
}else objDoc.execCommand(CMD_PASTE,UI_DEFAULT, null);
break;
case "EEPasteWord":
var strHtml=this._GetSavedHTML();
if(strHtml==null)objDoc.execCommand(CMD_PASTE,UI_DEFAULT, null);
else this._ClearAndInsertWordHtml(strHtml);
break;
case "EEEmotion":
this.InsertObj("FACE");
break;
case "EEFlash":
var objFlash=this.GetActive("OBJECT|EMBED",objE);
this.InsertObj("OBJECT",objFlash,"Flash");
break;
case "EEImage":
var objImage=this.GetActive("IMG",objE);
this.InsertObj("IMG",objImage);
break;
case "EEMedia":
var objMedia=this.GetActive("OBJECT|EMBED",objE);
this.InsertObj("OBJECT",objMedia,"Media");
break;
case "EEMarquee":
var objMarquee=this.GetActive("MARQUEE",objE);
this.InsertObj("MARQUEE",objMarquee);
break;
case "EESpecial":
this.InsertObj("SPECIAL");
break;
case "EETable":
case "EETableProperty":
var objTable=this.GetActive("TABLE",objE);
this.InsertObj("TABLE",objTable);
break;
case "EECellProperty":
var objTD=this.GetActive("TD",objE);
this.InsertObj("TD",objTD);
break;
case "EESplitCell":
var objTD=this.GetActive("TD",objE);
this.InsertObj("SPLITCELL",objTD);
break;
case "EEMergeCell":
EditorTableMergeCell();
break;
case "EEInsertRow":
EditorTableInsertRow();
break;
case "EEDeleteRow":
EditorTableInsertRow(1);
break;
case "EEInsertCol":
EditorTableInsertCol();
break;
case "EEDeleteCol":
EditorTableInsertCol(1);
break;
case "EEForm":
case "EEFormProperty":
var objForm=this.GetActive("FORM",objE);
this.InsertObj("FORM",objForm);
break;
case "EEFormFieldset":
this.InsertHTML('
'+this.Langs["FormFieldset"]+'
');
break;
case "EEFormImage":
case "EEFormText":
case "EEFormFile":
case "EEFormCheckBox":
case "EEFormRadio":
case "EEFormButton":
var objFImage=this.GetActive("INPUT",objE);
this.InsertObj("INPUT",objFImage,strId);
break;
case "EEFormTextArea":
var objTextArea=this.GetActive("TEXTAREA",objE);
this.InsertObj("TEXTAREA",objTextArea);
break;
case "EEFormSelect":
var objSelect=this.GetActive("SELECT",objE);
this.InsertObj("SELECT",objSelect);
break;
case "EEFormLabel":
var objLabel=this.GetActive("LABEL",objE);
this.InsertObj("LABEL",objLabel);
break;
case "EEInsertFile":
var objIFrame=this.GetActive("IFRAME",objE);
this.InsertObj("IFRAME",objIFrame);
break;
case "EELayer":
this.InsertHTML('
'+this.OtherLangs[3]+'
');
break;
case "EETab":
this.InsertHTML(" ");
break;
case "EEAnchor":
this.InsertObj("ANCHOR");
break;
case "EELink":
case "EEAnchorLink":
case "EEEmailLink":
var objA=this.GetActive("A",objE);
this.InsertObj("A",objA,strId);
break;
case "EEImageLink":
this.InsertObj("IMAGELINK");
break;
case "EEUnlink":
objActive.FrameWindow.document.execCommand(CMD_UNLINK,UI_DEFAULT,null);
break;
case "EECalendar":
var dat1=new Date();
var strDate=(numBrowser<=105.5)?dat1.toLocaleString().split(" ")[0]:dat1.toLocaleDateString();
this.InsertHTML(strDate);
break;
case "EETime":
var dat1=new Date();
var strTime=(numBrowser<=105.5)?dat1.toLocaleString().split(" ")[1]:dat1.toLocaleTimeString();
this.InsertHTML(strTime);
break;
case "EEUpLevel":
objDoc.execCommand(CMD_BRING_FORWARD,UI_DEFAULT, null);
break;
case "EEDownLevel":
objDoc.execCommand(CMD_SEND_BACKWARD,UI_DEFAULT, null);
break;
case "EEFirstLevel":
objDoc.execCommand(CMD_BRING_TO_FRONT,UI_DEFAULT, null);
break;
case "EELastLevel":
objDoc.execCommand(CMD_SEND_TO_BACK,UI_DEFAULT, null);
break;
case "EEControlProperty":
this.InsertObj("CONTROL");
break;
case "EEArt":
this.InsertObj("ART");
break;
case "EEClearArt":
var objArt=this.GetWordArt();
this.ClearArt(objActive,objArt);
break;
case "EECssProperty":
this.InsertObj("CSS");
break;
case "EEAbout":
this.InsertObj("ABOUT");
break;
case "EEHelp":
this.InsertObj("HELP");
break;
default:
this.Command(objActive,objE,objEvent);
}
this._DocOnSelectionChange(objEvent);
}
//清除艺术字
ETSOOEditor.ClearArt=function(objField,objE){
if(objE)objE.removeNode(true);
var objDocument=objField.FrameWindow.document;
var objShapeTypes=objDocument.getElementsByTagName("shapetype");
var numLen=objShapeTypes.length;
for(var numI=0;numI6)numLen-=2;
}else{
var strTag=strTarget.substr(2).toUpperCase();
var objTemp=this.GetTarget(objActive,strTag);
if(objTemp==null)numLen=2;
}
}
}
for(var numI=0;numI';
strContent+=' '+strLang+'';
}
}
return [strContent,numSub,numLine];
}
//处理菜单事件
ETSOOEditor.MenuClick=function(objE,_Add,objEvent){
var strTarget=objE.getAttribute("target");
if(strTarget!=""&&strTarget!=null){
var strId=objE.id;
var objTarget=this.GetObj(strTarget);
objTarget.id=strId;
objTarget.title=objE.title;
objTarget.src=objE.getElementsByTagName("img")[0].src;
ETSOOPopup.ActiveOne.SourceObject.setAttribute("target",strId);
}
ETSOOPopup.HideFrame(1);
this.MouseClick(objE,_Add,objEvent);
}
//是否为艺术字
ETSOOEditor.GetWordArt=function(){
var objE=this.ActiveTarget;
var objArt=this.GetTarget(objE,"SHAPE");
if(objArt==null)objArt=this.GetTarget(objE,"GROUP");
if(objArt)if(objArt.textpath.string=="")objArt=null;
return objArt;
}
//插入可操作对象
ETSOOEditor.InsertObj=function(strTagName,objE,_Add){
var strPage,numWidth,numHeight,arrAdd=[],blnAdd=false;
var objLangs=this.Langs;
if(objE==1){
blnAdd=true;
objE=null;
}else{
if(objE&&objE.nodeName!=strTagName){
if((strTagName=="OBJECT"&&objE.nodeName=="EMBED")||strTagName=="SPLITCELL"){}
else objE=null;
}else if(strTagName=="CONTROL"||strTagName=="CSS"||strTagName=="IMAGELINK")objE=this.ActiveTarget;
else if(strTagName=="ART")objE=this.GetWordArt();
}
var numType=1,strDAdd;
switch(strTagName){
case "IMG":
if(blnAdd)arrAdd=["Image",objLangs["ImageProperty"]];
else{
strPage="Image.htm", numWidth=720, numHeight=400;
}
break;
case "MARQUEE":
if(blnAdd)arrAdd=["Marquee",objLangs["MarqueeProperty"]];
else{
strPage="Marquee.htm", numWidth=420, numHeight=380;
}
break;
case "OBJECT":
case "EMBED":
if(_Add=="Flash"||_Add=="application/x-shockwave-flash"){
if(blnAdd)arrAdd=["Flash",objLangs["FlashProperty"]];
else{
strPage="Flash.htm", numWidth=720, numHeight=450;
}
}else if(_Add=="Media"){
if(blnAdd)arrAdd=["Media",objLangs["MediaProperty"]];
else{
strPage="Media.htm", numWidth=720, numHeight=450;
}
}else if(objE){
var strSrc;
if(strNodeName=="EMBED")strSrc=objE.src;
else strSrc=objE.Movie;
if(strSrc!=null&&strSrc.toLowerCase().indexOf(".swf")!=-1){
if(blnAdd)arrAdd=["Flash",objLangs["FlashProperty"]];
else{
strPage="Flash.htm", numWidth=720, numHeight=450;
}
}else if(objE.URL||objE.Controls){
if(blnAdd)arrAdd=["Media",objLangs["MediaProperty"]];
else{
strPage="Media.htm", numWidth=720, numHeight=450;
}
}
}
break;
case "TABLE":
if(blnAdd)arrAdd=["Table",objLangs["TableProperty"]];
else{
strPage="Table.htm", numWidth=500, numHeight=412;
}
break;
case "TD":
if(blnAdd)arrAdd=["CellProperty",objLangs["CellProperty"],"SplitCell",objLangs["SplitCell"],"InsertRow",objLangs["InsertRow"]];
else{
strPage="TableCell.htm", numWidth=420, numHeight=380;
}
break;
case "SPLITCELL":
if(!blnAdd){
strPage="TableCellSplit.htm", numWidth=240, numHeight=160;
}
break;
case "FORM":
if(blnAdd)arrAdd=["Form",objLangs["FormProperty"]];
else{
strPage="Form.htm", numWidth=400, numHeight=228;
}
break;
case "INPUT":
var strType;
if(blnAdd)strType=_Add;
else if(_Add)strType=_Add.substr(6).toLowerCase();
else if(objE)strType=objE.type;
var strAddId;
switch(strType){
case "image":
strAddId="FormImage";
if(blnAdd)arrAdd=[strAddId,objLangs[strAddId+"Property"]];
else{
strPage="Image.htm", numWidth=720, numHeight=420, strDAdd=2;
}
break;
case "radio":
strAddId="FormRadio";
case "checkbox":
if(strAddId==null)strAddId="CheckBox";
if(blnAdd)arrAdd=[strAddId,objLangs[strAddId+"Property"]];
else{
strPage="FormRadio.htm", numWidth=360, numHeight=200, strDAdd=strType;
}
break;
case "file":
strAddId="FormFile";
case "text":
case "password":
if(strAddId==null)strAddId="FormText";
if(blnAdd)arrAdd=[strAddId,objLangs[strAddId+"Property"]];
else{
strPage="FormText.htm", numWidth=360, numHeight=190, strDAdd=strType;
}
break;
case "button":
case "submit":
case "reset":
strAddId="FormButton";
if(blnAdd)arrAdd=[strAddId,objLangs[strAddId+"Property"]];
else{
strPage="FormButton.htm", numWidth=360, numHeight=170;
}
break;
}
break;
case "TEXTAREA":
if(blnAdd)arrAdd=["FormTextArea",objLangs["FormTextAreaProperty"]];
else{
strPage="FormTextArea.htm", numWidth=360, numHeight=264;
}
break;
case "SELECT":
if(blnAdd)arrAdd=["FormSelect",objLangs["FormSelectProperty"]];
else{
strPage="FormSelect.htm", numWidth=400, numHeight=336;
}
break;
case "LABEL":
if(blnAdd)arrAdd=["FormLabel",objLangs["FormLabelProperty"]];
else{
strPage="FormLabel.htm", numWidth=360, numHeight=170;
}
break;
case "IFRAME":
if(blnAdd)arrAdd=["InsertFile",objLangs["InsertFileProperty"]];
else{
strPage="IFrame.htm", numWidth=500, numHeight=360;
}
break;
case "FACE":
strPage="Face.htm", numWidth=600, numHeight=420,numType=0;
break;
case "FIND":
strPage="Find.htm", numWidth=412, numHeight=200, numType=0;
break;
case "SPECIAL":
strPage="Special.htm", numWidth=600, numHeight=270,numType=0;
break;
case "ANCHOR":
strPage="Anchor.htm", numWidth=360, numHeight=320;
break;
case "A":
if(blnAdd)arrAdd=["Link",objLangs["LinkProperty"]];
else{
strPage="Link.htm", numWidth=420, numHeight=280,strDAdd=_Add;
}
break;
case "IMAGELINK":
strPage="Area.htm", numWidth=640, numHeight=560;
break;
case "CONTROL":
strPage="Attribute.htm", numWidth=428, numHeight=480;
break;
case "CSS":
strPage="Css.htm", numWidth=640, numHeight=580;
break;
case "ART":
if(blnAdd)arrAdd=["Art",objLangs["ArtProperty"],"ClearArt",this.OtherLangs[6]];
else{
strPage="Art.htm", numWidth=600, numHeight=400;
}
break;
case "ABOUT":
strPage="http://www.etsoo.com/Products/EOEditor/About.asp?d="+document.domain, numWidth=510, numHeight=260;
break;
case "HELP":
strPage="http://www.etsoo.com/Products/EOEditor/", numWidth=640, numHeight=480, numType=-1;
break;
}
if(blnAdd){
objE=this.ActiveTarget;
var objT;
if(strTagName!="TABLE"){
objT=this.GetTarget(objE,"TABLE");
if(objT){
arrAdd=arrAdd.concat(["TableProperty",objLangs["TableProperty"]]);
}
}
if(strTagName!="TD"){
objT=this.GetTarget(objE,"TD");
if(objT){
arrAdd=arrAdd.concat(["CellProperty",objLangs["CellProperty"]]);
}
}
if(strTagName!="FORM"){
objT=this.GetTarget(objE,"FORM");
if(objT){
arrAdd=arrAdd.concat(["Form",objLangs["FormProperty"]]);
}
}
if(strTagName!="MARQUEE"){
objT=this.GetTarget(objE,"MARQUEE");
if(objT){
arrAdd=arrAdd.concat(["Marquee",objLangs["MarqueeProperty"]]);
}
}
if(strTagName!="A"){
objT=this.GetTarget(objE,"A");
if(objT){
arrAdd=arrAdd.concat(["Link",objLangs["LinkProperty"]]);
}
}
return arrAdd;
}
else if(strPage){
var arrControl=[0,0];
if(strPage.indexOf("http://")==-1)strPage=this.Path+"Dialogs/"+strPage;
else arrControl=[1,1];
var arrArgs=[self,objE,strDAdd];
window.ETSOOSavedArguments=arrArgs;
ETSOOPopup.Open(strPage,arrArgs,numWidth,ETSOOGetAdjustHeight(numHeight),numType,arrControl);
}
else return false;
}
//获取TDS
ETSOOEditor.GetTDs=function(){
var objField=this.ActiveField;
var objWindow=objField.FrameWindow;
var objSelection=objWindow.document.selection;
var arrTDs=[];
if(objSelection){
var objRange=objSelection.createRange();
var objParent
var blnAll=false;
if(objRange.length==null)objParent=objRange.parentElement();
else{
objParent=objRange(0);
if(objParent.nodeName=="TABLE")blnAll=true;
}
var objTD=this.GetTarget(objParent,"TD");
if(objTD){
arrTDs=[objTD];
}else{
var objTable=this.GetTarget(objParent,"TABLE");
if(objTable){
var arrTemp=objTable.getElementsByTagName("TD");
var numLen=arrTemp.length;
for(var numI=0;numI= 0&&objRange.compareEndPoints('StartToEnd',objCellRange)<= 0)||(objRange.compareEndPoints('EndToStart',objCellRange)>=0&&objRange.compareEndPoints('EndToEnd',objCellRange)<= 0))blnHave=true;
}else{
blnHave=true;
}
}
return blnHave;
}
//进行合规性判断
function EditorTableValid(objTD){
this.Valid==false;
this.TR;
this.Table;
if(objTD){
objTR=ETSOOEditor.GetTarget(objTD,"TR");
if(objTR){
objTable=ETSOOEditor.GetTarget(objTD,"TABLE");
if(objTable){
this.Valid=true;
this.TR=objTR;
this.Table=objTable;
}
}
}
}
//获取表格列数
function EditorTableGetCols(objTD,numMaxCol){
var numCols=0;
var objTR=ETSOOEditor.GetTarget(objTD,"TR");
if(objTR){
if(numMaxCol==null)numMaxCol=objTR.cells.length;
for(var numI=0;numI=numCellIndex)numRows+=objTempRow.cells(numCellIndex).rowSpan;
else numRow++;
}
}
return numRows;
}
//插入行
function EditorTableInsertRow(numType){
var objTDs=ETSOOEditor.GetTDs();
if(objTDs&&objTDs.length>0){
var objTD=objTDs[0];
var objValid=new EditorTableValid(objTD);
if(!objValid.Valid)return false;

var numCellIndex=objTD.cellIndex;
var objTR=objValid.TR;
var numRowIndex=objTR.rowIndex;
var objTable=objValid.Table;

if(numType==1){
objTR.removeNode(true);
if(objTable.rows.length==0)objTable.removeNode(true);
}
else{
var numCols=EditorTableGetCols(objTD);
var numI=0;
var objNewTR=objTable.insertRow(numRowIndex);
while(numI1)objTempTD.rowSpan+=1;
else
{
var objNewTD=objNewTR.insertCell();
objNewTD.innerHTML=" ";
objNewTD.mergeAttributes(objTempTD);
}
}
}
}
}
//插入列
function EditorTableInsertCol(numType){
var objTDs=ETSOOEditor.GetTDs();
if(objTDs&&objTDs.length>0){
var objTD=objTDs[0];
var objValid=new EditorTableValid(objTD);
if(!objValid.Valid)return false;

var numCellIndex=objTD.cellIndex;
var objTR=objValid.TR;
var numRowIndex=objTR.rowIndex;
var objTable=objValid.Table;

var numNowCols=EditorTableGetCols(objTD,numCellIndex);
var numRows=objTable.rows.length;
for(var numI=0;numI=numNowCols){
if(numTempColsAdd>1)objTempTD.colSpan-=1;
else{
objTempTD.removeNode(true);
if(objTempTR.cells.length==0)
{
objTempTR.removeNode(true);
numI--;
}
}
}
}
else
{
if(numTempCols>numNowCols){
if(numTempColsAdd>1)objTempTD.colSpan+=1;
else{
var objNewTD=objTempTR.insertCell(numI);
objNewTD.innerHTML=" ";
objNewTD.mergeAttributes(objTempTD);
}
}
}
}
}
}
}
//合并单元格
function EditorTableMergeCell(numType){
var objTDs=ETSOOEditor.GetTDs();
var numLen=objTDs.length;
if(numLen>1){
var objBaseTD=objTDs[0];
var objValid=new EditorTableValid(objBaseTD);
if(!objValid.Valid)return false;

var numBaseCellIndex=objBaseTD.cellIndex;
var objBaseTR=objValid.TR;
var numBaseRowIndex=objBaseTR.rowIndex;
var objBaseTable=objValid.Table;
var strText='';

for(var numI=1;numI<=numTempCells){
var objTempTD=objTempTR.cells(numCellIndex);
numTempRows+=objTempTD.rowSpan;
}
else numTempRows++;
}
}
numRowSpan=numRows-numTempRows;

var numNewRowIndex;
if(numRowIndex==numRows-1)numNewRowIndex=numRowIndex-1;
else numNewRowIndex=numRowIndex+1;
var objNewTR=objBaseTable.rows(numNewRowIndex);
var numCols=EditorTableGetCols(objNewTR.cells(0));

var numNowCols=EditorTableGetCols(objBaseTD)-objBaseTD.colSpan;

numColSpan=numCols-numNowCols;

objBaseTD.colSpan=numColSpan;
objBaseTD.rowSpan=numRowSpan;
}
}
}
}
//设置颜色
ETSOOEditor.SetColor=function(strColor,strId){
var objTarget=this.GetObj(strId);
if(objTarget){
objTarget.nextSibling.style.backgroundColor=strColor;
this.MouseClick(objTarget);
}
}
//获取对象
ETSOOEditor._GetEventObj=function(objEvent){
if(objEvent)return (objEvent.srcElement)?objEvent.srcElement:objEvent.target;
}
//获取活动编辑域
ETSOOEditor._GetActiveField=function(strId){
var numPos=strId.indexOf("ETSOOEditorFrame_");
if(numPos==0)strId=strId.substr(17);
var objOne=this.Fields[strId];
if(objOne!=null)this.ActiveField=objOne;
return objOne;
}
//编辑域获得焦点
ETSOOEditor._FrameOnFocus=function(objEvent){
var objTarget=ETSOOEditor._GetEventObj(objEvent);
var objActive=ETSOOEditor._GetActiveField(objTarget.id);
if(objActive&&ETSOOEditor.Browser>100)objActive.History.Add();
ETSOOEditor._DocOnSelectionChange(objEvent);
}
//编辑域失去焦点
ETSOOEditor._FrameOnBlur=function(numType){
ETSOOEditor._SaveContent();
if(ETSOOEditor.Browser>100){
var objActive=ETSOOEditor.ActiveField;
if(objActive)objActive.History.Add(1);
}
}
//保存内容到隐藏文本框
ETSOOEditor._SaveContent=function(strName,numType){
var objField;
if(strName!=null)objField=this.Fields[strName];
else{
objField=ETSOOEditor.ActiveField;
numType=1;
}
if(objField&&objField.FrameWindow.document.body){
if(objField.TextArea.style.display=="none"){
var strContent=objField.FrameWindow.document.body.innerHTML;
if(ETSOOEditor.Browser>100)strContent=this.GetRelativePath(strContent);
objField.TextArea.value=strContent;
}
else if(numType==1)objField.FrameWindow.document.body.innerHTML=objField.TextArea.value;
}
}
//表单提交
ETSOOEditor._FormOnSubmit=function(objEvent){
var objTextArea=ETSOOEditor._GetEventObj(objEvent).getElementsByTagName("textarea");
var numLen=objTextArea.length;
for(var numI=0;numI100)objField.History.Add();
break;
case 71: //G
ETSOOEditor.InsertObj("FACE");
break;
case 75: //K
var objE;
if(objActive.tagName=="A")objE=objActive;
ETSOOEditor.InsertObj("A",objE);
break;
case 76: //L
objDoc.execCommand(CMD_LEFT,UI_DEFAULT,null);
if(numBrowser>100)objField.History.Add();
break;
case 77: //M
var objE;
if(objActive.tagName=="IMG")objE=objActive;
ETSOOEditor.InsertObj("IMG",objE);
break;
case 82: //R
objDoc.execCommand(CMD_RIGHT,UI_DEFAULT,null);
if(numBrowser>100)objField.History.Add();
break;
case 89: //Y
if(numBrowser>100)objField.History.Go(1);
else objDoc.execCommand(CMD_REDO,UI_DEFAULT, null);
break;
case 90: //Z
if(numBrowser>100)objField.History.Go(-1);
else objDoc.execCommand(CMD_UNDO,UI_DEFAULT, null);
break;
case 189: //-
case 109:
if(numBrowser<100)break;
var objDecrease=ETSOOEditor._GetNamedDiv(objField.Div,"Decrease");
if(objDecrease)ETSOOEditor.MouseClick(objDecrease);
break;
case 187:
case 107:
if(numBrowser<100)break;
var objIncrease=ETSOOEditor._GetNamedDiv(objField.Div,"Increase");
if(objIncrease)ETSOOEditor.MouseClick(objIncrease);
break;
default:
blnSet=false;
}
if(blnSet){
ETSOOEditor._FrameOnBlur();
ETSOOEditor.CancelBubble(objEvent);
return false;
}
}
}
//获得指定名称的Div
ETSOOEditor._GetNamedDiv=function(objDiv,strName){
var arrDivs=objDiv.getElementsByTagName("div");
var numLen=arrDivs.length;
for(var numI=0;numI100)objEvent.cancelBubble=true;
else objEvent.preventDefault();
}
//动态获取对象
ETSOOEditor._GetMenuItem=function(objEvent){
var objLangs=this.Langs;
var arrItems=new Array("SelectAll",objLangs["SelectAll"],"PasteWord",objLangs["Paste"]);
var objCut=this.GetObj("EECut");
if(objCut&&objCut.className!="Disabled"){
arrItems=arrItems.concat("NewLine","","Cut",objLangs["Cut"],"Copy",objLangs["Copy"],"Delete",objLangs["Delete"]);
}
var objE=this._GetEventObj(objEvent);
if(objE.nodeName=="BODY"&&this.Browser>100){
var objRange=this.ActiveField.FrameWindow.document.selection.createRange();
if(objRange.length!=null)objE=objRange(0);
}
this.ActiveTarget=objE;
var strNodeName=objE.nodeName;
var strType=objE.type;
if(strNodeName=="OBJECT"){
if(objE.Movie)strType="Flash";
else strType="Media";
}
if(this.GetWordArt())strNodeName="ART";
var arrAdd=this.InsertObj(strNodeName,1,strType);
var numLen=arrAdd.length;
if(numLen>0){
arrItems=arrItems.concat("NewLine","");
arrItems=arrItems.concat(arrAdd);
}
if(objE.nodeName!="BODY"){
if(numLen==0)arrItems=arrItems.concat("NewLine","");
arrItems=arrItems.concat("ControlProperty",this.OtherLangs[4],"CssProperty",this.OtherLangs[5]);
}
return arrItems;
}
//编辑域粘贴
ETSOOEditor._DocOnPaste=function(){
if(ETSOOEditor.AutoClearWord){
var strHtml=ETSOOEditor._GetSavedHTML();
var regWord=/<\w[^>]* class="?MsoNormal"?/gi;
if(regWord.test(strHtml)){
ETSOOEditor._ClearAndInsertWordHtml(strHtml);
return false;
}
}
}
//编辑域Word文件信息
ETSOOEditor._GetSavedHTML=function(){
var strHtml;
if(ETSOOEditor.Browser>=105.5){
var objDiv=document.getElementById("ETSOOEditorTempleData");
objDiv.innerHTML="";
var objRange=document.body.createTextRange();
objRange.moveToElementText(objDiv);
objRange.execCommand("Paste");
strHtml=objDiv.innerHTML;
objDiv.innerHTML="";
}else if(window.clipboardData){
strHtml=window.clipboardData.getData("Text");
if(strHtml==null)strHtml="";
strHtml=strHtml.replace(/\n\n/gi,"

"); strHtml=strHtml.replace(/\n/gi,"
"); strHtml=strHtml.replace(/( ){2}/gi," "); strHtml=strHtml.replace(/( ){5,}/gi," " ); } return strHtml; } //去除多余字符 ETSOOEditor._ClearAndInsertWordHtml=function(strHtml){ strHtml=strHtml.replace(/<\/?SPAN[^>]*>/gi,""); strHtml=strHtml.replace(/<(\w[^>]*)\s+class=([^ |>]*)([^>]*)/gi,"<$1$3"); strHtml=strHtml.replace(/<(\w[^>]*)\s+style="([^"]*)"([^>]*)/gi,"<$1$3"); strHtml=strHtml.replace(/<(\w[^>]*)\s+lang=([^ |>]*)([^>]*)/gi,"<$1$3"); strHtml=strHtml.replace(/<\\?\?xml[^>]*>/gi,""); strHtml=strHtml.replace(/<\/?\w+:[^>]*>/gi,""); strHtml=strHtml.replace(/( ){5,}/gi," " ); this.InsertHTML(strHtml); } //选择域发生变化 ETSOOEditor._DocOnSelectionChange=function(strAction,strAdd){ if(ETSOOEditor.ReadyState==0)return; if(!ETSOOEditor.ActiveStatus)return; var arrObj=ETSOOEditor.GetRange(); if(arrObj==null)return false; var objBody=arrObj[1]; var objSelection=arrObj[2]; var objRange=arrObj[3]; var objTarget,numType=0; var numAbsPos=0,numCut=0; var numBrowser=ETSOOEditor.Browser; if(objRange){ if(objRange.length==null){ objTarget=objRange.parentElement(); if(objTarget){ var numNodeType=objTarget.nodeType; var strText=objRange.text; if(numNodeType==1||numNodeType==3){ if(objTarget.nodeName=="BODY"||objTarget.nodeName=="BR")numCut=-1; if(objTarget.nodeName=="BODY"&&strText!="")numCut=0; if(numNodeType==3||numBrowser>100)numCut=(strText=="")?-1:0; }else{ numCut=-1; } } }else{ objTarget=objRange(0); } if(objTarget&&objTarget.style&&objTarget.style.position=="absolute")numAbsPos=1; } ETSOOEditor.ActiveTarget=objTarget; ETSOOEditor._SetButton("AbsolutePos",numAbsPos); if(numCut==-1)ETSOOEditor.SetDefault("EELink"); ETSOOEditor._SetButton("Cut",numCut); ETSOOEditor._SetButton("Copy",numCut); ETSOOEditor._SetButton("Delete",numCut); ETSOOEditor._SetButton("Link",numCut); var strFont=ETSOOEditor._GetValue(objTarget,"FONT;","face",null,0); if(numBrowser<100&&!strFont)strFont=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontFamily",null,1); ETSOOEditor._SetButton("FontSet",strFont); var strSize=strSize=ETSOOEditor._GetValue(objTarget,"FONT;","size",null,0); if(numBrowser<100&&!strSize)strSize=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontSize",null,1); ETSOOEditor._SetButton("FontSize",strSize); if(ETSOOEditor.GetTarget(objTarget,"B")!=null||ETSOOEditor.GetTarget(objTarget,"STRONG")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontWeight","bold",1))numType=1; ETSOOEditor._SetButton("Bold",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"I")!=null||ETSOOEditor.GetTarget(objTarget,"EM")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontStyle","italic",1))numType=1; ETSOOEditor._SetButton("Italic",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"U")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","underline",1))numType=1; ETSOOEditor._SetButton("Underline",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"STRIKE")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","line-through",1))numType=1; ETSOOEditor._SetButton("StrikeThrough",numType);numType=0; if(ETSOOEditor._GetValue(objTarget,"P;","align","left",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","left",1))numType=1; ETSOOEditor._SetButton("Left",numType);numType=0; if(ETSOOEditor._GetValue(objTarget,"P;","align","center",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","center",1))numType=1; ETSOOEditor._SetButton("Center",numType);numType=0; if(ETSOOEditor._GetValue(objTarget,"P;","align","right",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","right",1))numType=1; ETSOOEditor._SetButton("Right",numType);numType=0; if(ETSOOEditor._GetValue(objTarget,"P;","align","justify",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","jusfity",1))numType=1; ETSOOEditor._SetButton("Full",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"OL")!=null)numType=1; ETSOOEditor._SetButton("OrderList",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"UL")!=null)numType=1; ETSOOEditor._SetButton("UnorderList",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"SUP")!=null)numType=1; ETSOOEditor._SetButton("SuperScript",numType);numType=0; if(ETSOOEditor.GetTarget(objTarget,"SUB")!=null)numType=1; ETSOOEditor._SetButton("SubScript",numType);numType=0; var objTable=ETSOOEditor.GetTarget(this.ActiveTarget,"TABLE"); if(objTable==null)ETSOOEditor.SetDefault("EETable"); var objForm=ETSOOEditor.GetTarget(this.ActiveTarget,"FORM"); if(objForm==null)ETSOOEditor.SetDefault("EEForm"); } //恢复默认图标 ETSOOEditor.SetDefault=function(strId){ var objDiv=this.MenuBar; if(objDiv==null)return false; var arrImages=objDiv.getElementsByTagName("IMG"); var numLen=arrImages.length; for(var numI=0;numI=0){ if(strSrc.indexOf("disabled.gif")!=-1)objE.src=this.GetImgSrc(strId); if(numType==0)this.MouseOut(objE); else{ if(strId!="MORE"){ this.MouseDown(objE); objE.className="Keep"; } } }else if(numType==-1){ if(strSrc.indexOf("disabled.gif")==-1)objE.src=this.GetImgSrc(strId+"DISABLED"); this.MouseOut(objE); objE.className="Disabled"; } } //获得目标 ETSOOEditor.GetTarget=function(objE,strTagName){ while(objE&&(objE.nodeName.toUpperCase()!=strTagName))objE=objE.parentNode; return objE; } //模式切换 ETSOOEditor._SetMode=function(objDocument,strValue){ var blnIE5=(objDocument.body.contentEditable==null); var blnValue=(strValue=="on")?true:false; if(blnIE5)objDocument.designMode=strValue; else objDocument.body.contentEditable=blnValue; return blnIE5; } //获得字符集 ETSOOEditor._GetCharset=function(){ return (this.Browser>100)?document.defaultCharset:document.characterSet; } //设置颜色提示显示 ETSOOEditor._SetShow=function(strId){ var objShow=this.GetObj(strId+"_Show"); if(objShow==null)return false; var objImg=this.GetObj(strId); var arrPos=ETSOOGetPos(objImg); var numLeft=arrPos[0]+4; var numTop=arrPos[1]+16; if(window.Node){ numLeft-=1; numTop-=1; } var strBgColor=(strId=="EEForeColor")?"#000000":"#FFFFFF"; with(objShow.style){ backgroundColor=strBgColor; left=numLeft+"px"; top=numTop+"px"; display="block"; } } //初始化设置编辑域 ETSOOEditor._SetFieldContent=function(){ var blnIE=(this.Browser>100); var blnIE5=(this.Browser==105); var blnHave=false; var blnActiveStatus=this.ActiveStatus; for(strField in this.Fields){ if(!blnHave)blnHave=true; var objField=this.Fields[strField]; if(this.ActiveField==null)this.ActiveField=objField; var strBaseContent=objField.Content; var objTextArea=objField.TextArea; if(objTextArea.value!="")strBaseContent=objTextArea.value; else objTextArea.value=strBaseContent; var objDiv=objField.Div; var numShowMode=objDiv.getAttribute("ShowMode"); var objDocument=objField.FrameWindow.document; var numShowMargin=objField.Div.getAttribute("ShowMargin"); var strPath=this.Path; if(blnIE) { objField.History=new this.History(objField); objField.History.Data[0]=strBaseContent; window.attachEvent("onbeforeunload",this._FrameOnBlur); objField.FrameDocument.attachEvent("onfocus",this._FrameOnFocus); var strCharset=this._GetCharset(); var strBody=''; strBody+=''; strBody+='\n'; if(!blnIE5){ objField.FrameDocument.attachEvent("onblur",this._FrameOnBlur); } else{ document.attachEvent("onmousedown",this._FrameOnBlur); window.attachEvent("onblur",this._FrameOnBlur); } strBody+='\n'; strBody+='\n'; strBody+='\n'; strBody+=''; objDocument.open(); objDocument.write(strBody); objDocument.close(); objDocument.execCommand("LiveResize",false,true); objDocument.execCommand("2D-Position",false,true); objDocument.execCommand("MultipleSelection",false,true); this._SetMode(objDocument,"on"); }else{ window.addEventListener('unload',this._FrameOnBlur , true); objDocument.addEventListener('blur',this._FrameOnBlur , true); objDocument.addEventListener('focus',this._FrameOnFocus , true); objDocument.addEventListener('mousedown',this._DocOnClick , true); objDocument.addEventListener('keydown',this._DocOnKeyPress , true); objDocument.addEventListener('contextmenu',this._DocOnContextMenu , true); objDocument.addEventListener('dblclick',this._DocOnDblClick , true); objDocument.addEventListener('mouseup',this._DocMouseUp, true); if(blnActiveStatus)objDocument.addEventListener('keyup',this._DocOnSelectionChange , true); var objBody=objDocument.body; var objHead=objDocument.createElement("head"); objHead=objDocument.documentElement.insertBefore(objHead,objBody); var objStyle=objDocument.createElement("style"); objStyle.innerHTML='TD,OBJECT,EMBED,FORM{border:1px dotted #111111};A{padding-left:12px;background-image:url('+strPath+'Images/anchor_show.gif);background-repeat:no-repeat}'; objHead.appendChild(objStyle); objBody.bgColor="#FFFFFF"; with(objBody.style){ margin=(numShowMargin==0?0:12)+"px"; fontSize="9pt"; } objBody.innerHTML=strBaseContent; objDocument.id=objField.FrameDocument.id; objDocument.designMode="on"; } if(numShowMode==1||numShowMode==2){ var objOneDiv=objDiv.getElementsByTagName("div")[0]; ETSOOEditor.MouseDown(objOneDiv); this.MouseClick(objOneDiv,true); } objDiv.style.visibility="visible"; } this._SetShow("EEForeColor"); this._SetShow("EEBgColor"); ETSOOPopup._SetAddEvent(window); if(blnIE&&!blnIE5){ var objDiv=document.createElement("div"); objDiv.id="ETSOOEditorTempleData"; with(objDiv.style){ visibility="hidden"; } objDiv.setAttribute("contentEditable",true); document.body.insertAdjacentElement("beforeEnd",objDiv); } if(blnHave){ this.ReadyState=1; if(blnIE){ if(blnActiveStatus){ this._SetButton("Redo",-1); this._SetButton("Undo",-1); } var numLen=document.forms.length; for(var numI=0;numI100)window.attachEvent("onload",function(){ETSOOEditor._SetFieldContent()}); else window.addEventListener("load",function(){ETSOOEditor._SetFieldContent()},false); //执行execCommand命令 ETSOOEditor.Command=function(objActive,objE,objEvent){ var strId=objE.id; var objDoc=objActive.FrameWindow.document; var blnCode=(objActive.Mode=="Code"); if(strId.indexOf("EE")==0)strId=strId.substr(2); if(objE.className=="Keep"&&(strId=="Center"||strId=="Right"||strId=="Full"))strId="Left"; var strPath=this.Path; var strWord=""; var blnActiveStatus=this.ActiveStatus; switch(strId){ case "Redo": if(this.Browser>100&&blnActiveStatus)objActive.History.Go(1); else objDoc.execCommand(CMD_REDO,UI_DEFAULT, null); break; case "Undo": if(this.Browser>100&&blnActiveStatus)objActive.History.Go(-1); else objDoc.execCommand(CMD_UNDO,UI_DEFAULT, null); break; case "FontSet": if(blnCode)strWord='*'; else{ var strFont=objE.value; if(strFont=="")strFont=null; objDoc.execCommand(CMD_FONTSET,UI_DEFAULT, strFont); } break; case "FontSize": if(blnCode)strWord='*'; else{ var numSize=objE.value; if(numSize=="")numSize=null; objDoc.execCommand(CMD_FONTSIZE,UI_DEFAULT,numSize); } break; case "BgColor": var strColor=objE.nextSibling.style.backgroundColor; objDoc.execCommand(CMD_BGCOLOR,UI_DEFAULT,strColor); break; case "ForeColor": var strColor=objE.nextSibling.style.backgroundColor; objDoc.execCommand(CMD_FORECOLOR,UI_DEFAULT,strColor); break; default: strWord=null; if(blnCode){ switch(strId){ case "Bold": strWord="*"; break; case "Italic": strWord="*"; break; case "Underline": strWord="*"; break; case "StrikeThrough": strWord="*"; break; case "Left": case "Center": case "Right": case "Full": strWord='

*
';
break;
case "SuperScript":
strWord='*';
break;
case "SubScript":
strWord='*';
break;
}
}
break;
}
if(blnCode&&strWord!=null)this.InsertHTML(strWord,1);
else if(strWord!=""){
objDoc.execCommand(eval("CMD_"+strId.toUpperCase()),UI_DEFAULT, null);
}
if(this.Browser>100&&strId!="Redo"&&strId!="Undo")objActive.History.Add();
}
//获得Range及相关对象
ETSOOEditor.GetRange=function(){
var objField=this.ActiveField;
if(objField==null)return false;
var strMode=objField.Mode;
if(strMode=="Preview")return;
var objWindow,objBody,objSelection,objRange;
if(strMode=="Code"){
objWindow=window;
objBody=objField.TextArea;
}else{
objWindow=objField.FrameWindow;
objBody=objWindow.document.body;
}
initDom(objWindow);
try{
objSelection=objWindow.document.selection;
objRange=objSelection.createRange();
}catch(e){}
return [objWindow,objBody,objSelection,objRange,strMode];
}
//插入html代码
ETSOOEditor.InsertHTML=function(strContent,numType){
var arrObj=this.GetRange();
if(arrObj==null)return false;
var objBody=arrObj[1];
var objSelection=arrObj[2];
var objRange=arrObj[3];
var strMode=arrObj[4];
var numBrowser=this.Browser;
var objSavedRange=window.ETSOOEditorSavedRange;
if(numBrowser==105.5&&objSavedRange)if(!objBody.contains(objRange.parentElement()))objRange=objSavedRange;
if(objSelection.type=="Control"||objBody.contains(objRange.parentElement())){
if(strMode=="Code"){
if(numType==1)objRange.text=strContent.replace(/\*/gi,objRange.text);
else objRange.text=strContent;
}else{
if(objSelection.type!="None"){
objSelection.clear();
objRange=objSelection.createRange();
}
objRange.pasteHTML(strContent);
}
objRange.select();
objRange.collapse(false);
}
if(numBrowser>100)this.ActiveField.History.Add();
}
/* 导入静态资源 */
var strSource='\n';
strSource+='\n';
strSource+='\n';
strSource+='\n';
document.write(strSource);
strSource=null;

/* 类属性和方法 */
ETSOOEditor.prototype.Language=_BaseLanguage;
ETSOOEditor.prototype.BgColor="#D4D0C8";
ETSOOEditor.prototype.ContentType=0;
ETSOOEditor.prototype.ShowMargin=1;
ETSOOEditor.prototype.ShowMode=1;
ETSOOEditor.prototype.Width="100%";
ETSOOEditor.prototype.Type=0;
ETSOOEditor.prototype.ErrorCode=0;
ETSOOEditor.prototype.Skin="System";
ETSOOEditor.prototype.ViewControl=[1,1,1,1,1];
//获取语言文本
ETSOOEditor._GetLang=function(objLangDoc,arrIds){
var arrLangs=[];
var numLen=arrIds.length;
for(var numI=0;numI100);
var objXMLDom=objEditor.XMLDom;
objXMLDom.async=false;
objXMLDom.load(strPath+"languages/"+strLanguage+"/System.xml");
var objLangDoc=objXMLDom.documentElement;
var langMore=objLangDoc.getElementsByTagName("More")[0].firstChild.nodeValue;
objEditor.ModeLangs=objEditor._GetLang(objLangDoc,["Design","Code","Preview","Increase","Decrease"]);
objEditor.OtherLangs=objEditor._GetLang(objLangDoc,["NewTip","DefaultColor","MoreColor","LayerText","ControlProperty","CssProperty","ClearArt"]);
objEditor.WindowLangs=objEditor._GetLang(objLangDoc,["Confirm","Cancel","Close"]);
var numContentType=this.ContentType;
if(numContentType==2)return "";
objXMLDom.load(strPath+"Skins/"+numType+".xml");
var objBarDoc=objXMLDom.documentElement;

var strTools='
'; else{ var objNode=objLangDoc.getElementsByTagName(strName)[0]; if(strName=="FontSet"||strName=="FontSize"){ var numSubLen=objNode.childNodes.length; var arrFonts=[]; strTools+='\n'; }else { var strLang=objNode.firstChild.nodeValue; objEditor.Langs[strName]=strLang; var strLangAdd=objNode.getAttribute("AddLang"); if(strLangAdd!=null)objEditor.Langs[strName+"Property"]=strLangAdd; strName="EE"+strName; strTools+=objEditor._GetImgStr(strPath,strBgColor,20,20,strName,strLang); if(strName=="EEForeColor"||strName=="EEBgColor"){ strTools+='0){ for(var numS=0;numS0||strName=="EEForeColor"||strName=="EEBgColor"){ if(arrMenu.length>0)objEditor.SubMenu[strName]=arrMenu; strTools+=objEditor._GetImgStr(strPath,strBgColor,7,20,"EEMore",langMore,strName); } } } strTools+=''; } } } strTools+='\n'; strTools+='
';
return strTools;
}
//设置图片显示
ETSOOEditor.prototype._SetImage=function(){
var objEditor=ETSOOEditor.MenuBar;
if(objEditor==null)return;
var arrImages=objEditor.getElementsByTagName("img");
var numLen=arrImages.length;
for(var numI=0;numI\n';


总数:3 页次:1/1 首页 尾页  
总数:3 页次:1/1 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1