南强小屋 Design By 杰米
代码还有待完善:
复制代码 代码如下:<script type="text/javascript">
// Close HTML Tags --------------------------------------------
function closeHTML(str){
var arrTags=["span","font","b","u","i","h1","h2","h3","h4","h5","h6","p","li","ul","table","div"];
for(var i=0;i<arrTags.length;i++){
var intOpen=0;
var intClose=0;
var re=new RegExp("\\<"+arrTags[i]+"( [^\\<\\>]+|)\\>","ig");
var arrMatch=str.match(re);
if(arrMatch!=null) intOpen=arrMatch.length;
re=new RegExp("\\<\\/"+arrTags[i]+"\\>","ig");
arrMatch=str.match(re);
if(arrMatch!=null) intClose=arrMatch.length;
for(var j=0;j<intOpen-intClose;j++){
str+="</"+arrTags[i]+">";
}
/*for(var j=(intOpen-intClose-1);j>=0;j--){
str+="</"+arrTags[i]+">";
}*/
}
return str;
}
// Close UBB Tags --------------------------------------------
function closeUBB(str){
var arrTags=["code","quote","list","color","align","font","size","b"];
for(var i=0;i<arrTags.length;i++){
var intOpen=0;
var intClose=0;
var re=new RegExp("\\["+arrTags[i]+"(=[^\\[\\]]+|)\\]","ig");
var arrMatch=str.match(re);
if(arrMatch!=null) intOpen=arrMatch.length;
re=new RegExp("\\[\\/"+arrTags[i]+"\\]","ig");
arrMatch=str.match(re);
if(arrMatch!=null) intClose=arrMatch.length;
for(var j=0;j<intOpen-intClose;j++){
str+="[/"+arrTags[i]+"]";
}
}
return str;
}
alert(closeHTML("正常:<div class='testBox'><ul><li><b>加粗</b><span>字体哈哈"));
alert(closeHTML("有错:<div class='testBox'><p><ul><li><b>加粗</b><span>字体哈哈"));
</script>
复制代码 代码如下:<script type="text/javascript">
// Close HTML Tags --------------------------------------------
function closeHTML(str){
var arrTags=["span","font","b","u","i","h1","h2","h3","h4","h5","h6","p","li","ul","table","div"];
for(var i=0;i<arrTags.length;i++){
var intOpen=0;
var intClose=0;
var re=new RegExp("\\<"+arrTags[i]+"( [^\\<\\>]+|)\\>","ig");
var arrMatch=str.match(re);
if(arrMatch!=null) intOpen=arrMatch.length;
re=new RegExp("\\<\\/"+arrTags[i]+"\\>","ig");
arrMatch=str.match(re);
if(arrMatch!=null) intClose=arrMatch.length;
for(var j=0;j<intOpen-intClose;j++){
str+="</"+arrTags[i]+">";
}
/*for(var j=(intOpen-intClose-1);j>=0;j--){
str+="</"+arrTags[i]+">";
}*/
}
return str;
}
// Close UBB Tags --------------------------------------------
function closeUBB(str){
var arrTags=["code","quote","list","color","align","font","size","b"];
for(var i=0;i<arrTags.length;i++){
var intOpen=0;
var intClose=0;
var re=new RegExp("\\["+arrTags[i]+"(=[^\\[\\]]+|)\\]","ig");
var arrMatch=str.match(re);
if(arrMatch!=null) intOpen=arrMatch.length;
re=new RegExp("\\[\\/"+arrTags[i]+"\\]","ig");
arrMatch=str.match(re);
if(arrMatch!=null) intClose=arrMatch.length;
for(var j=0;j<intOpen-intClose;j++){
str+="[/"+arrTags[i]+"]";
}
}
return str;
}
alert(closeHTML("正常:<div class='testBox'><ul><li><b>加粗</b><span>字体哈哈"));
alert(closeHTML("有错:<div class='testBox'><p><ul><li><b>加粗</b><span>字体哈哈"));
</script>
标签:
关于HTML及UBB标记的闭合
南强小屋 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
南强小屋 Design By 杰米
暂无关于HTML及UBB标记的闭合的评论...