<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>HTML 2 UBB</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JavaScript>
<!--
function SymError()
{
return true;
}
window.onerror = SymError;
function html_trans(str) {
str = str.replace(/\r/g,"");
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/<script[^>]*?>([\w\W]*?)<\/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]");
str = str.replace(/<([\/]?)u>/ig,"[$1u]");
str = str.replace(/<([\/]?)i>/ig,"[$1i]");
str = str.replace(/ /g," ");
str = str.replace(/&/g,"&");
str = str.replace(/"/g,"\"");
str = str.replace(/</g,"<");
str = str.replace(/>/g,">");
str = str.replace(/<br>/ig,"\n");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
str = str.replace(/\n+/g,"\n");
return str;
}
function trans(){
var str = "";
rtf.focus();
rtf.document.body.innerHTML = "";
rtf.document.execCommand("paste");
str = rtf.document.body.innerHTML;
if(str.length == 0) {
alert("提示,剪切板中没有文本内容!");
return "";
}
return html_trans(str);
}
function CopyTextToPastBoad(v_TextboxName) {
if (document.all(v_TextboxName).value == '') {
alert('提示,文本框中没有代码!');
return false;
}
document.all(v_TextboxName).select();
js = document.all(v_TextboxName).createTextRange();
js.execCommand('Copy');
alert('成功,已将文本框中的代码复制到剪切板上!');
}
//-->
</SCRIPT>
<STYLE type=text/css>TD {
FONT-SIZE: 12px; FONT-FAMILY: Arial, Helvetica, sans-serif
}
TEXTAREA {
FONT-SIZE: 12px; FONT-FAMILY: Arial, Helvetica, sans-serif
}
INPUT {
FONT-SIZE: 12px; FONT-FAMILY: Arial, Helvetica, sans-serif
}
.tt {
FONT-WEIGHT: bolder; FONT-SIZE: 16px
}
a {text-decoration="none"; font-size: 12px;}
</STYLE>
<META content="MSHTML 6.00.2900.2722" name=GENERATOR>
<base target="_blank">
</HEAD>
<BODY>
<IFRAME id=rtf style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME>
<LABEL for=x_paste></LABEL>
<TABLE style="FONT-SIZE: 12px" cellSpacing=1 cellPadding=10 align=center bgColor=#00ccff border=0>
<TR>
<TD class=tt align=middle height=30>HTML 2 UBB</TD></TR>
<TR>
<TD align=middle bgColor=#ffffff>
<TEXTAREA class=textarea onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}" id=bbcodetext rows=23 cols=100></TEXTAREA>
</TD>
</TR>
<TR>
<TD align=middle bgColor=#ffffff>
<INPUT onclick="document.getElementById('bbcodetext').value ='' " type=reset value=清空文本框>
<INPUT onclick="document.getElementById('bbcodetext').value = trans()" type=button value=转换(覆盖) name=button>
<INPUT onclick="document.getElementById('bbcodetext').value += trans()" type=button value=转换(追加) name=button>
<INPUT onclick="CopyTextToPastBoad('bbcodetext')" type=button value=复制到剪切板 name=button>
</TD>
</TR>
<TR>
<TD align=middle bgColor=#ffffff>
<SCRIPT>rtf.document.designMode="On";</SCRIPT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
[转帖]html2ubb
最新推荐文章于 2021-03-23 01:38:42 发布