/**
*@authortin555
*/
functionsetHTML(html){
ContentEdit.value=html;
eWebEditor.document.designMode="On";
eWebEditor.document.open();
eWebEditor.document.write(html);
eWebEditor.document.body.contentEditable="true";
eWebEditor.document.execCommand("2D-Position",true,true);
eWebEditor.document.execCommand("MultipleSelection",true,true);
eWebEditor.document.execCommand("LiveResize",true,true);
eWebEditor.document.close();
eWebEditor.document.body.onpaste=onPaste;
//eWebEditor.document.body.onhelp=onHelp;
//eWebEditor.document.body.ondragend=newFunction("returndoDragEnd();");
eWebEditor.document.onkeydown=newFunction("returnonKeyDown(eWebEditor.event);");
//eWebEditor.document.oncontextmenu=newFunction("returnshowContextMenu(eWebEditor.event);");
//eWebEditor.document.onmousedown=newFunction("returnonMouseDown();");
//eWebEditor.document.onmouseup=newFunction("returnonMouseUp();");
}
functiongetHTML(){
varhtml;
html=eWebEditor.document.body.innerHTML;
if((html.toLowerCase()=="<p></p>")||(html.toLowerCase()=="<p></p>")){
html="";
}
returnhtml;
}
functioninsertHTML(html){
eWebEditor.focus();
if(eWebEditor.document.selection.type.toLowerCase()!="none"){
eWebEditor.document.selection.clear();
}
eWebEditor.document.selection.createRange().pasteHTML(html);
}
functionappendHTML(html){
if(eWebEditor.document.selection.type.toLowerCase()!="none"){
eWebEditor.document.selection.clear();
}
eWebEditor.document.body.innerHTML+=html;
}
functiondoDragEnd(){
varoSelection=eWebEditor.document.selection.createRange();
varsRangeType=eWebEditor.document.selection.type;
if(sRangeType=="Control"){
varoControl=oSelection.item(0);
if(oControl.tagName=="IMG"){
oControl.src=FullPath2SetPath(oControl.src);
}
}
if(sRangeType=="Text"){
varels=eWebEditor.document.body.getElementsByTagName("IMG");
varoRngTemp=eWebEditor.document.body.createTextRange();
for(vari=0;i<els.length;i++){
oRngTemp.moveToElementText(els(i));
if(oSelection.inRange(oRngTemp)){
els(i).src=FullPath2SetPath(els(i).src)
}
}
}
returntrue;
}
functiononKeyDown(event){
varn_KeyCode=event.keyCode;
if(n_KeyCode==13){
returnfalse;
}
}
varoResizing=newObject;
functiononMouseDown(){
oResizing.El=null;
if(eWebEditor.document.selection.type=="Control"){
varoControlRange=eWebEditor.document.selection.createRange();
oResizing.El=oControlRange(0);
oResizing.W=oResizing.El.style.width;
oResizing.H=oResizing.El.style.height;
}
}
functionGetClipboardHTML(){
varoDiv=document.getElementById("eWebEditor_Temp_HTML");
oDiv.innerHTML="";
varoTextRange=document.body.createTextRange();
oTextRange.moveToElementText(oDiv);
oTextRange.execCommand("Paste");
varsData=oDiv.innerHTML;
oDiv.innerHTML="";
returnsData;
}
functioncleanAndPaste(html){
html=html.replace(/</?SPAN[^>]*>/gi,"");
html=html.replace(/<(w[^>]*)class=([^|>]*)([^>]*)/gi,"<$1$3");
html=html.replace(/<(w[^>]*)style="([^"]*)"([^>]*)/gi,"<$1$3");
html=html.replace(/<(w[^>]*)lang=([^|>]*)([^>]*)/gi,"<$1$3");
html=html.replace(/<??xml[^>]*>/gi,"");
html=html.replace(/</?w+:[^>]*>/gi,"");
html=html.replace(//,"");
insertHTML(html);
}
functiononPaste(){
varsHTML=GetClipboardHTML();
varre=/<w[^>]*class="?MsoNormal"?/gi;
if(re.test(sHTML)){
if(confirm("你要粘贴的内容好象是从Word中拷出来的,是否要先清除Word格式再粘贴?")){
cleanAndPaste(sHTML);
returnfalse;
}
}
}