时间: 2021-07-31 作者:daque
/ 清除WORD冗余格式并粘贴function cleanandpaste( html ) { // remove all span tags html = html.replace(/<\/?span[^>]*>/gi, "" ); // remove class attributes html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ; // remove style attributes html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ; // remove lang attributes html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ; // remove xml elements and declarations html = html.replace(/<\\?\?xml[^>]*>/gi, "") ; // remove tags with xml namespace declarations: <o:p></o:p> html = html.replace(/<\/?\w+:[^>]*>/gi, "") ; // replace the html = html.replace(/ /, " " ); // transform <p> to <div> var re = new regexp("(<p)([^>]*>.*?)(<\/p>)","gi") ; // different because of a ie 5.0 error html = html.replace( re, "<div$2</div>" ) ; inserthtml( html ) ;}