這個功能主要是讓 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]");