document.write('\n');
var userAgent1 = navigator.userAgent.toLowerCase();
var htmledit_ispaste = false;
//判断浏览器是否为firefox,且非ie/chrome
if(/mozilla/.test(userAgent1) && !/(compatible|webkit)/.test(userAgent1))
{
HTMLElement.prototype.insertAdjacentHTML = function(where, html)
{
var e = this.ownerDocument.createRange();
e.setStartBefore(this);
e = e.createContextualFragment(html);
switch (where){
case 'beforeBegin' :
this.parentNode.insertBefore(e, this);
break;
case 'afterBegin' :
this.insertBefore(e, this.firstChild);
break;
case 'beforeEnd' :
this.appendChild(e);
break;
case 'afterEnd' :
if( ! this.nextSibling) this.parentNode.appendChild(e);
else this.parentNode.insertBefore(e, this.nextSibling);
break;
}
};
if(typeof(HTMLElement)!="undefined" && !window.opera){
HTMLElement.prototype.__defineGetter__("outerHTML",function()
{
var a=this.attributes, str="<"+this.tagName, i=0;for(;i";
return str+">"+this.innerHTML+""+this.tagName+">";
});
HTMLElement.prototype.__defineSetter__("outerHTML",function(s)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var df = r.createContextualFragment(s);
this.parentNode.replaceChild(df, this);
return s;
});
HTMLElement.prototype.__defineGetter__("canHaveChildren",function()
{
return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
});
}
}
//判断浏览器是否为firefox,且可为firefox/chrome (compatible 为ie)
if(/mozilla/.test(userAgent1) && /(firefox|webkit)/.test(userAgent1))
{
/* 会导致FF和chrome下出错,暂屏蔽
Object.prototype.attachEvent=function(method,func)
{
if(!this[method])
this[method]=func;
else
this[method]=this[method].attach(func);
};
Function.prototype.attach=function(func){
var f=this;
return function(){
f();
func();
};
};*/
}
function CleanWord( html, bIgnoreFont, bRemoveStyles ){
//html = clipboardData.getData("Text");
//return html;
//var html = oNode.innerHTML ;
if(bIgnoreFont==undefined)bIgnoreFont=true;
if(bRemoveStyles==undefined)bRemoveStyles=true;
html = html.replace(/\s*<\/o:p>/g, '') ;
html = html.replace(/[\s\S]*?<\/o:p>/g, ' ') ;
// Remove mso-xxx styles.
html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;
// Remove margin styles.
html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ;
html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;
html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;
// Remove FONT face attributes.
if ( bIgnoreFont ) {
html = html.replace( /\s*face="[^"]*"/gi, '' ) ;
html = html.replace( /\s*face=[^ >]*/gi, '' ) ;
html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;
}
// Remove Class attributes
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove styles.
if ( bRemoveStyles )
html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
// Remove style, meta and link tags
html = html.replace( /\n'
+ '\n'
+ ''
+ contents
+ '\n'
+ '