这个功能主要是让 UBB 转贴的时候方便点.
1.自动识别图片,超链接,字体颜色,和字体加粗,倾斜,下划线的HTML代码,并且转换为UBB代码.
2.兼容 IE 和 Mozilla多种浏览器
<html>
<head>
<title>Html转换程序</title>
<SCRIPT language="JavaScript1.2">
function HtmlToUBB(str) {
str = str.replace(/r/g,"");
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/<script[^>]*?>([wW]*?)</script>/ig,"");
str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)</a>/ig,"n[url=$1]$2[/url]n");
str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)</font>/ig,"n[color=$1]$2[/color]n");
str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"n[img]$1[/img]n");
str = str.replace(/<([/]?)b>/ig,"[$1b]");
str = str.replace(/<([/]?)strong>/ig,"[$1b]");