对联 ·故事 ·史海钩沉 ·人物档案 ·地方风俗 ·谚语大全 ·讽刺与幽默 · 赚钱 · 法律 · 在线教研 · 会员中心 · 心理测试 · 魔鬼词典 · 顺口溜
 
主页特效 网页特效 百家姓
娱乐 歇后语 绕口令 脑筋急转弯
 
谚语 谜语 名言 邮政编码
便民 酒方 验方 偏方 站长工具  
 
算命 风俗 手相 爱情
女孩 音乐 面相 星座 血型
 
饮食 穴道 偏方 医药
生活 软件 硬件 解梦 高考



   JS特效



实用工具
便民服务 加密解密
 
魅力高密 民间故事 Flash教程 PS教程 最新国内新闻
新华字典 黄道吉日 英语园地  万年历 Html2anycode
  首页 | 美图 | 短信 | 安全 | 校园 | 网站 | 游戏 | UFO | 文秘 | 生活 | 信息技术 | 论文 | 人生 | 情感 | 日记
返回首页
当前位置: 主页 > 网站建设 >

清理word垃圾代码

时间:2012-07-03 12:39来源:未知 作者:qianqian 点击:
将如下文件保存为html文件,然后运行就可以看到效果了: script language=javascript !-- function cleanWordString( html ) { html = html.replace(/\/?SPAN[^]*/gi, );// Remove all SPAN tags html = html.replace(/(\w[^]*) clas
  

将如下文件保存为html文件,然后运行就可以看到效果了:

<script  language=javascript> 
<!-- 
function  cleanWordString(  html  )  { 
           html  =  html.replace(/<\/?SPAN[^>]*>/gi,  ""  );//  Remove  all  SPAN  tags 
           html  =  html.replace(/<(\w[^>]*)  class=([^    |>]*)([^>]*)/gi,  "<$1$3")  ;  //  Remove  Class  attributes 
           //html  =  html.replace(/<(\w[^>]*)  style="([^"]*)"([^>]*)/gi,  "<$1$3")  ;  //  Remove  Style  attributes 
           html  =  html.replace(/<(\w[^>]*)  lang=([^    |>]*)([^>]*)/gi,  "<$1$3")  ;//  Remove  Lang  attributes 
           html  =  html.replace(/<\\?\?xml[^>]*>/gi,  "")  ;//  Remove  XML  elements  and  declarations 
           html  =  html.replace(/<\/?\w+:[^>]*>/gi,  "")  ;//  Remove  Tags  with  XML  namespace  declarations:  <o:p></o:p> 
           html  =  html.replace(/&nbsp;/,  "  "  );//  Replace  the  &nbsp; 
           //  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  )  ; 
           test.b.value  =  html 

//--> 
</script> 
<form  id=test> 
<textarea  name=a  cols=60  rows=13></textarea><br> 
<textarea  name=b  cols=60  rows=13  ID="b"></textarea> 
<input  type=button  onclick="cleanWordString(test.a.value);"  value=转换> 
</form>


 

顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
赞助商位置
推荐内容
杂七杂八