正 文

用省略号格式化数据标题


www.7dspace.com  更新日期:2006-2-27 4:59:05  七度空间


5,为了方便,做成函数

<%
function conleft(content,i)
if len(content)>i then 
content=left(content,i)   
response.write (content&"...")
else
response.write (content)
end if
end function
%>

以上为函数,下面就可以直接调用。

<%call conleft(rs("content"),10)%>

OK,相信以后遇到这些问题应该是NO PROBLEM

为了解决中英文截取的问题,做如下函数:

function gotTopic(str,strlen)
    if str="" then
        gotTopic=""
        exit function
    end if
    dim l,t,c, i
    str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
    l=len(str)
    t=0
    for i=1 to l
        c=Abs(Asc(Mid(str,i,1)))
        if c>255 then
            t=t+2
        else
            t=t+1
        end if
        if t>=strlen then
            gotTopic=left(str,i) & "…"
            exit for
        else
            gotTopic=str
        end if
    next
    gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
end function

2页,页码:[1] [2] 

上一篇:ASP中常见的错误80004005信息
下一篇:如何使数据库中取出的数据保持原有格式
用省略号格式化数据标题 作者:cnbruce 来源:blog
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐