<div class="codetitle"> <span><a style="CURSOR: pointer" data="46703" class="copybut" id="copybut46703" onclick="doCopy('code46703')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code46703"> <br><script type="text/javascript"> <BR>// Close HTML Tags -------------------------------------------- <BR>function closeHTML(str){ <BR>var arrTags=["span","font","b","u","i","h1","h2","h3","h4","h5","h6","p","li","ul","table","div"]; <BR>for(var i=0;i<arrTags.length;i++){ <BR>var intOpen=0; <BR>var intClose=0; <BR>var re=new RegExp("\\<"+arrTags[i]+"( [^\\<\\>]+|)\\>","ig"); <BR>var arrMatch=str.match(re); <BR>if(arrMatch!=null) intOpen=arrMatch.length; <BR>re=new RegExp("\\<\\/"+arrTags[i]+"\\>","ig"); <BR>arrMatch=str.match(re); <BR>if(arrMatch!=null) intClose=arrMatch.length; <BR>for(var j=0;j<intOpen-intClose;j++){ <BR>str+="</"+arrTags[i]+">"; <BR>} <BR>/*for(var j=(intOpen-intClose-1);j>=0;j--){ <BR>str+="</"+arrTags[i]+">"; <BR>}*/ <BR>} <BR>return str; <BR>} <BR></script> <br> </div>