页面字符串过滤函数
作者:cmscn 日期:2006-12-02
<%
'****************************************************
'页面字符串过滤函数,返回值
'作者:www.joekoe.com论坛用户(cuiwl)
'****************************************************
function codehtml(str,n1,n2)
'str字符串参数
'n1过滤等级
'n2显示数目
if trim(str)="" then
codehtml=""
exit function
end if
select case n1
case 0
'不过滤
str=str
case 1
'无段落文本格式
str=replace(str,"<","<")
str=replace(str,">",">")
case 2
'有段落文本格式
str=replace(str,"<","<")
str=replace(str,">",">")
str=replace(str,"chr(10)","<br>")
str=replace(str,chr(32)," ")'空格
str=replace(str,vbcrlf,"<p>") '回车
case 3
'有段落html格式,支持表格、图片、列表等功能
str=replace(str,"<","<")
str=replace(str,">",">")
str=replace(str,"chr(10)","<br>")
str=replace(str,chr(32)," ")'空格
str=replace(str,vbcrlf,"<p>") '回车
str=replace(str,"<p","<p")
str=replace(str,"p>","p>")
str=replace(str,"<br","<br")
str=replace(str,"br>","br>")
str=replace(str,"<hr","<hr")
str=replace(str,"hr>","hr>")
str=replace(str,"<b","<b")
str=replace(str,"b>","b>")
str=replace(str,"<u","<u")
str=replace(str,"u>","u>")
str=replace(str,"<i","<i")
str=replace(str,"i>","i>")
str=replace(str,"<ol","<ol")
str=replace(str,"ol>","ol>")
str=replace(str,"<ul","<ul")
str=replace(str,"ul>","ul>")
str=replace(str,"<li","<li")
str=replace(str,"li>","li>")
str=replace(str,"<font","<font")
str=replace(str,"font>","font>")
str=replace(str,"<table","<table")
str=replace(str,"table>","table>")
str=replace(str,"<tr","<tr")
str=replace(str,"tr>","tr>")
str=replace(str,"<td","<td")
str=replace(str,"td>","td>")
str=replace(str,"<div","<div")
str=replace(str,"div>","div>")
str=replace(str,"<img","<img")
str=replace(str,"img>","img>")
str=replace(str,"<a","<a")
str=replace(str,"a>","a>")
end select
select case n2
case 0
'显示全部
str=str
case else
'显示部分
if len(str)<=n2 then
str=str
else
str=left(str,n2-1)&".."
end if
end select
codehtml=str
end function
%>
调用方式:
codehtml(rs("word"),3,0)
codehtml(rs("name"),1,8)
codehtml(rs("remark"),2,100)
评论: 3 | 引用: 0 | 查看次数: 797
发表评论