正则使用及去除html注释(富文本编辑器生成的兼容性脚本)
<script type="text/javascript">
String.prototype.trim = function () {//删除左右两端的空格
return this.replace(/(^\s*)|(\s*$)/g, "");
}
window.onload = function () {
var ohtml = document.getElementById("selfhtml");
var html = ohtml.innerHTML;
html = html.replace(/<!--[\s\S]*?-->/ig, ''); //去除html注释
html = html.replace(/>\s+([^\s<]*)\s+</ig, '>$1<').trim(); //去除html标签间的多余空白
ohtml.innerHTML = html;
};
</script>
--******************************************************************************************************************
---================================================================================================================
//whs_outdtl_ctgbth_positionid = "~~99G06/E!99G06/E!99G06/E!99G06-E!99G06-E!";
//whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid.replace(/[\/,-]/ig, "");
//alert(whs_outdtl_ctgbth_positionid);
//LXH_IsLingHuo_LStr_CtgBth = "~~99G06/E!99G06/E!99G06/E!99G06-E!99G06-E!";
//whs_outdtl_ctgbth_positionid = "~~99G06-E!";
//whs_outdtl_ctgbth_positionid = "99G06/E";
whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid.replace(/[\/,-]/ig, "");
whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid+"!"
LXH_IsLingHuo_LStr_CtgBth = LXH_IsLingHuo_LStr_CtgBth.replace(/[\/,-]/ig, "");
var regExp = new RegExp(whs_outdtl_ctgbth_positionid, 'ig');
LXH_IsLingHuo_LStr_CtgBth = LXH_IsLingHuo_LStr_CtgBth.replace(regExp, "");
$$LXH_IsLingHuo_LStr_CtgBth.val(LXH_IsLingHuo_LStr_CtgBth);
if (LXH_IsLingHuo_LStr_CtgBth === "~~") {
$$hidIsLingHuo.val('n');
}
---================================================================================================================

浙公网安备 33010602011771号