function onPaste() { var sHTML = GetClipboardHTML() ; var re = /<\w[^>]* class="?MsoNormal"?/gi ; if ( re.test(sHTML)){ if ( confirm( "你要粘贴的内容好象是从Word中拷出来的,是否要先清除Word格式再粘贴?" ) ) { alert(cleanAndPaste( sHTML )) ; } } }// 清除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>" ) ; return html; }// 取剪粘板中的HTML格式数据 function GetClipboardHTML() { var oDiv = document.getElementById("eWebEditor_Temp_HTML") oDiv.innerHTML = "" ; var oTextRange = document.body.createTextRange() ; oTextRange.moveToElementText(oDiv) ; oTextRange.execCommand("Paste") ; var sData = oDiv.innerHTML ; oDiv.innerHTML = "" ; return sData ; }
var sHTML = GetClipboardHTML() ;
var re = /<\w[^>]* class="?MsoNormal"?/gi ;
if ( re.test(sHTML)){
if ( confirm( "你要粘贴的内容好象是从Word中拷出来的,是否要先清除Word格式再粘贴?" ) )
{
alert(cleanAndPaste( sHTML )) ;
}
}
}// 清除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>" ) ; return html;
}// 取剪粘板中的HTML格式数据
function GetClipboardHTML() {
var oDiv = document.getElementById("eWebEditor_Temp_HTML")
oDiv.innerHTML = "" ; var oTextRange = document.body.createTextRange() ;
oTextRange.moveToElementText(oDiv) ;
oTextRange.execCommand("Paste") ; var sData = oDiv.innerHTML ;
oDiv.innerHTML = "" ; return sData ;
}
lover(孟子E章) 这个是需要购买的
<IMG class=Ico height=16 src="images\copy.gif" width=16>
</div>
<div class="Btn" TITLE="粘贴" LANGUAGE="javascript" onclick="format1('paste');">
<IMG class=Ico height=16 src="images\paste.gif" width=16>
</div>在编辑器页面如上所示,在该JS中function format1(what,opt)怎么搞?