87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script>
function getvalue() {
var s=document.getElementById("TA").value;
var str=ubbtohtml(s);
document.getElementById("TA").value=str;
//document.getElementById("Button1").onclick(); //无限递归了
}
function ubbtohtml(str ){
if(str){
str=str.replace(/\[URL\](http:\/\/(\S+?))\[\/URL\]/g," <A HREF='$1' TARGET=_blank>$2 </A>");
}
return str;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<textarea id="TA" cols="100" rows="5" runat="server"></textarea>
<input id="Button1" type="button" runat="server" value="button" onclick="getvalue();" onserverclick="Button1_ServerClick" />
</form>
</body>
</html>
str=str.replace("/\[URL\])(http:\/\/\S+?)(\[\/URL\]/g"," <A HREF='$2' TARGET=_blank>$2 </A>");
改为
str=str.replaceAll("\[URL\])(http:\/\/\S+?)(\[\/URL\]"," <A HREF='$2' TARGET=_blank>$2 </A>");