UBB编辑器问题:为什么插入媒体文件(如.rm和.wma)后,在页面上不能被转换?

hacker18 2006-01-24 02:44:05
我使用的是动网的HTML编辑器,其有设计、UBB、预览、源码四个模式,在UBB模式中,为什么插入媒体文件(如.rm和.wma)后,在页面上不能被转换?后来仔细分析,发现是UBBCode.asp中相关的正则表达式有问题。
谁有完整的UBB编辑器源程序?问题解决,立即结帖!
QQ:309331800
电邮:lushui24@sohu.com

有耐心的朋友可以阅读一下下面的源代码。

---------------------------------------------------------------------------------------------------------------
post.js

/*不能转换,因为指定了宽度和高度。
function Cswf() {
if (helpstat){
alert("Flash\nFlash 动画.\n用法: [flash=宽度, 高度]Flash 文件的地址[/flash]");
} else if (basic) {
AddTxt="[flash=500,350][/flash]";
AddText(AddTxt);
} else {
txt2=prompt("flash宽度,高度","500,350");
if (txt2!=null) {
txt=prompt("Flash 文件的地址","http://");
if (txt!=null) {
if (txt2=="") {
AddTxt="[flash=500,350]"+txt;
AddText(AddTxt);
AddTxt="[/flash]";
AddText(AddTxt);
} else {
AddTxt="[flash="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/flash]";
AddText(AddTxt);
}
}
}
}
}
*/

//可以转换。
function Cswf() {
if (helpstat){
alert("Flash 动画\n插入 Flash 动画.\n用法: [flash]Flash 文件的地址[/flash]");
} else if (basic) {
AddTxt="[flash][/flash]";
AddText(AddTxt);
} else {
txt=prompt("Flash 文件的地址","http://");
if (txt!=null) {
AddTxt="[flash]"+txt;
AddText(AddTxt);
AddTxt="[/flash]";
AddText(AddTxt);
}
}
}

---------------------------------------------------------------------------------------------------------------
ubbcode.asp

'不能转换,因为指定了宽度和高度。

if instr(1,strContent,"[flash]",1)>0 then
re.Pattern="(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"
strContent= re.Replace(strContent,"<a href=""$2"" TARGET=_blank><IMG SRC=editor/images/swf.gif border=0 alt=点击开新窗口欣赏该FLASH动画! height=16 width=16>[全屏欣赏]</a><br><OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400><PARAM NAME=movie VALUE=""$2""><PARAM NAME=quality VALUE=high><embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400>$2</embed></OBJECT>")
end if
...全文
127 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hacker18 2006-02-05
  • 打赏
  • 举报
回复
不行哟!
尚和空四 2006-01-25
  • 打赏
  • 举报
回复
<%
function UBBCode(strContent)
dim objRegExp
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=True

'换行
objRegExp.Pattern="(\[br\])"
strContent=objRegExp.Replace(strContent,"<br/>")
'下划线
objRegExp.Pattern="(\[u\])(.+?)(\[\/u\])"
strContent=objRegExp.Replace(strContent,"<u>$2</u>")
'斜体
objRegExp.Pattern="(\[i\])(.+?)(\[\/i\])"
strContent=objRegExp.Replace(strContent,"<i>$2</i>")
'加粗
objRegExp.Pattern="(\[b\])(.+?)(\[\/b\])"
strContent=objRegExp.Replace(strContent,"<b>$2</b>")
'双横线
objRegExp.Pattern="(\[QUOTE\])(.+?)(\[\/QUOTE\])"
strContent=objRegExp.Replace(strContent,"<BLOCKQUOTE><font size=2 face=""Verdana, Arial"">引用:</font><HR>$2<HR></BLOCKQUOTE>")
'红色
objRegExp.Pattern="(\[red\])(.+?)(\[\/red\])"
strContent=objRegExp.Replace(strContent,"<FONT COLOR=""#ff0000"">$2</FONT>")
'灰色
objRegExp.Pattern="(\[gray\])(.+?)(\[\/gray\])"
strContent=objRegExp.Replace(strContent,"<FONT COLOR=""#77ACAC"">$2</FONT>")
'绿色
objRegExp.Pattern="(\[green\])(.+?)(\[\/green\])"
strContent=objRegExp.Replace(strContent,"<FONT COLOR=""#009933"">$2</FONT>")
'蓝色
objRegExp.Pattern="(\[blue\])(.+?)(\[\/blue\])"
strContent=objRegExp.Replace(strContent,"<FONT COLOR=""#0055ff"">$2</FONT>")
'任何颜色字
objRegExp.Pattern="(\[color\=)(.+?)(\])(.+?)(\[\/color\])"
strContent=objRegExp.Replace(strContent,"<FONT COLOR=""$2"">$4</FONT>")
'电子邮件
objRegExp.Pattern="(\[EMAIL\])(\S+\@\S+?)(\[\/EMAIL\])"
strContent= objRegExp.Replace(strContent,"<A HREF=""mailto:$2"">$2</A>")
'带链接的文字
objRegExp.Pattern="(\[URL\])(http:\/\/\S+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"<A HREF=""$2"" TARGET=_blank>$2</A>")
objRegExp.Pattern="(\[URL\])(\S+?)(\[\/URL\])"
strContent= objRegExp.Replace(strContent,"<A HREF=""http://$2"" TARGET=_blank>$2</A>")
'滚动
objRegExp.Pattern="(\[marquee\])(.+?)(\[\/marquee\])"
strContent=objRegExp.Replace(strContent,"<marquee scrollamount='3' id=xxskybbs onmouseover=xxskybbs.stop() onmouseout=xxskybbs.start()>$2</marquee>")
'回滚
objRegExp.Pattern="(\[marqueea\])(.+?)(\[\/marqueea\])"
strContent=objRegExp.Replace(strContent,"<marquee behavior=""alternate"" scrollamount='3' id=xxskybbs onmouseover=xxskybbs.stop() onmouseout=xxskybbs.start()>$2</marquee>")
'带链接的图片
objRegExp.Pattern="(\[IMGurl\=)(http:\/\/\S+?)(\])(http:\/\/\S+?)(\[\/IMGurl\])"
strContent=objRegExp.Replace(strContent,"<a href=""$2"" target=_blank><IMG SRC=""$4"" border=0 onload=""javascript:if(this.width>screen.width-366)this.width=screen.width-366""></a>")
objRegExp.Pattern="(\[IMGurl\=)(\S+?)(\])(\S+?)(\[\/IMGurl\])"
strContent=objRegExp.Replace(strContent,"<a href=""http://$2"" target=_blank><IMG SRC=""http://$4"" border=0 onload=""javascript:if(this.width>screen.width-366)this.width=screen.width-366""></a>")
'图片
objRegExp.Pattern="(\[IMG\])(\S+?)(\[\/IMG\])"
strContent=objRegExp.Replace(strContent,"<IMG SRC=""$2"">")


set objRegExp=Nothing
UBBCode=strContent
end function
Response.Write UBBCode(Replace(Request.Form("a"),vbCrLf,"<br/>"))
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧