Word
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
</HEAD>
<BODY>
<script>
function getclipboardhtml ()
{
var odiv = document.getElementById ("Divtemp")
odiv.innerhtml = "";
var otextrange = Document.body.createTextRange ();
Otextrange.movetoelementtext (ODIV);
Otextrange.execcommand ("Paste");
var sData = odiv.innerhtml;
odiv.innerhtml = "";
return sData;
}
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 (/<]*>/gi >)\\?\?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);
return HTML;
Form1.my.value = html;
}
function Paste ()
{
var SHTML = getclipboardhtml ();
var re =/<\w[^>]* class= "? MsoNormal "?/gi;
var Re2 =/<\w[^>]* class= "? xl"?/gi;
if (Re.test (SHTML))
{
Alert ("The content you want to paste appears to be from MS Word, the system clears MS Word formatting and then pastes it!") ")
}
if (Re2.test (SHTML))
{
Alert ("The content you want to paste appears to be from MS Excel, the system clears MS Excel formatting and then pastes it!") ")
}
Cleanandpaste (SHTML);
}
</script>
<form id= "Form1" name= "Form1" >
<input type= "button" value= "Paste" >
<br/>
<br/>
<textarea name= "My" cols= "rows=" ></textarea>
<div id=divtemp
Style= "Visibility:hidden; Overflow:hidden; width:1px; Position:absolute; height:1px "></DIV>
</Form>
</BODY>
</HTML>