您的位置:首页 > Web前端 > JavaScript

JS正则过滤(去除)富文本编辑器中的FONT-SIZE标签

2017-02-10 11:38 218 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS正则过滤编辑器样式font-size:xx;</title>
<script language="javascript">
function show(){
var test="<p>\n\t<img src=\"http://localhost/Scripts/KindEditor/Editor/plugins/emoticons/images/0.gif\" alt=\"\" border=\"0\" />ds<em>fds</em>\n</p>\n<p>\n\ts<span style=\"font-size:16px;\">dfd</span>sf<img src=\"http://localhost/Scripts/KindEditor/Editor/plugins/emoticons/images/19.gif\" alt=\"\" border=\"0\" />ds<strong>fdsfds</strong>\n</p>\n<p>\n\t<br />\n<strong></strong>\n</p>\n<p align=\"center\">\n\t<strong>d<span style=\"font-family:FangSong_GB2312;\">ssa</span>dasasdsad<u>dfds</u><br />\n</strong>\n</p>";
var test=test.replace(/font-size:\w+;?/g,'');
document.getElementById("sd").innerHTML=test;
}
</script>
</head>

<body onload="show();">
<div id="sd"></div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息