千分给一人!!求助关于格式转换问题!!!!
有一款再线html文档编辑器提供从word中复制转换功能。
可以把word文当中的格式给去掉。
但其中有些瑕疵。导致,每缎文章开头原来空两个,他却不空。一股脑儿的把所有style给去掉。
下面我贴出实例文档代码。供参考
<P style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一排不空
<P style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第二排空两个字
<P style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第三排空两个字
<P style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第四排不空
<P style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第五排不空
<P style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 32.25pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第六排空三个字
<P style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 32.25pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第七排空三个字。</SPAN></P></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
以上是事例代码。
下面是转换函数
function word()
{
HtmlEdit.document.execCommand("Paste",false);
var editBody=HtmlEdit.document.body;
for(var intLoop=0;intLoop el=editBody.all[intLoop];
el.removeAttribute("className","",0);
el.removeAttribute("style","",0);
el.removeAttribute("font","",0);
}
var html=HtmlEdit.document.body.innerHTML;
html=html.replace(/ <\/o:p>/g,"");
html=html.replace(/o:/g,"");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(/
/g, "");
html=html.replace(/<\/P>/g, "");
html=html.replace(/<\/SPAN>/g, "");
HtmlEdit.document.body.innerHTML = html;
format('selectall');
format('RemoveFormat');
}
好了。我们来分析一下。这个转换函数一股脑儿把所有代码给replace掉了。
转换函数没有分析这个
中是否有style=''"
现在需要修改成,遇到style=""则不过滤掉
具体怎么修改呢!?请高人赐教。谢谢
请搞人在那个转换函数基础上修改。如成功,分数全给您