给HTML加引号,标记变小写.

<textarea style="height:300px; width:600px;">
<UL class=list>
<LI class=feed_item><SPAN class=note>01/12/2008</SPAN>
<P><A title=GE公司推出“汪力和李邦”网络广告 href="http://www.genewscenter.com/content/Detail.asp?ReleaseID=4886&amp;NewsAreaID=2&amp;changeCurrentLocale=5" _eventID="4">GE公司推出“汪力和李邦”网络广告</A></P></LI>
<LI class=feed_item><SPAN class=note>26/11/2008</SPAN>
<P><A title=GE石油天然气集团在中国创造新的快速安装记录 href="http://www.genewscenter.com/content/Detail.asp?ReleaseID=4879&amp;NewsAreaID=2&amp;changeCurrentLocale=5" _eventID="5">GE石油天然气集团在中国创造新的快速安装记录</A></P></LI></UL>
</textarea>
<script type="text/javascript">
var partialXHTML = function (value) {
    return value.replace(/<(\/?[a-zA-Z]+\s*)((?:"[^"]*"|'[^']*'|(?!'|"|\/?>).)*)(\/?>)/g, function (l, $1, $2, $3) {
        return '<' + $1.toLowerCase() + $2.replace(/([^=]+)=(?:(")[^"]*"|(')[^']*'|((?:(?!\s|'|"|\/?>).)*))/g, function (l, $1, $2, $3, $4) {
            return ($2||$3) ? l : $1 + '="' + $4 + '"';
        }) + $3;
    });
};
var parse = function (t) {
    t.value = partialXHTML(t.value);
};
</script>
<input type="button" value="修正" onclick="parse(document.getElementsByTagName('textarea')[0])" />
posted @ 2008-12-02 11:59  越兔  阅读(857)  评论(3编辑  收藏  举报