function dropformat(oname,nname){ var o =document.getElementById(oname); var ot = o.value; var result = proc(ot); if(result){ document.getElementById(nname).value=result; document.getElementById('showtable').innerHTML= result;
}else{ alert('处理出错!'); } returnfalse; }
function proc(str){
var p =/<\s*(table|tr|td|tbody|thead|th)[^>]*>/img; e= str.replace(p,function($0,$1,$2){ var hm=$0; var m=$1; switch(m.toUpperCase()){ case'TABLE': return'
'; break; case'TR': return'
'; case'TD': var k =/colspan\s*=(\s|'|")*\d+(\s|'|")*/img;
var ma = hm.match(k);
var et = '
if(ma !=null){
et = et+ ma[0]+' ';
}
var k =/rowspan\s*=(\s|'|")*\d+(\s|'|")*/img;
var ma = hm.match(k);
if(ma !=null){
et = et+ma[0] +'';
}
return et +'>';
case 'THEAD':
return '<thead>';
case 'TH':
return '<th>';
case 'TBODY':
return '<tbody>';
default:
}
});
var e = e.replace(/<[ |\r|\n| ]*p[^>]*>/img,'');
var e = e.replace(/<[ |\r|\n| ]*\/[ |\r|\n| ]*p[^>]*>/img,'');
var e = e.replace(/<[ |\r|\n| ]*span[^>]*>/img,'');
var e = e.replace(/<[ |\r|\n| ]*\/[ |\r|\n| ]*span[^>]*>/img,'');
var e = e.replace(/<\s*div[^>]*>/img,'');
var e = e.replace(/<\s*\/[ |\r|\n| ]*div[^>]*>/img,'');
var e = e.replace(/<\/o:p>/img,'');
var e = e.replace(/<[ |\r|\n| ]*strong[^>]*>/img,'');
var e = e.replace(/<[ |\r|\n| ]*\/[ |\r|\n| ]*strong[^>]*>/img,'');
var e = e.replace(/[ |\r|\n| ]{2,}/img,'');
var e = e.replace(/<[ |\r|\n| ]*font[^>]*>/img,'');
var e = e.replace(/<[ |\r|\n| ]*\/[ |\r|\n| ]*font[^>]*>/img,'');
var e = e.replace(/