js过滤word格式
By admin
- One minute read - 106 wordsfunction cleanAndPaste(html) …{ // Remove all SPAN tags html = html.replace(/]>/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: html = html.replace(/]>/gi, “”) ; // Replace the html = html.replace(/ /, ” ” ); // Transform
to
var re = new RegExp(“(]*>.*?)(
)”,”gi”) ; // Different because of a IE 5.0 error html = html.replace( re, “” ) ;
return html; }