<% text=rs("content") '将数据库字段值赋到某变量上 i=10 '定义固定大小 if len(text)>i then '如果文本长度大于给定的值 text=left(text,i) '则提取前段的i位的字符串 response.write (text&"...") else response.write (text) end if %>
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 %>
cnpn Publish at 2005-8-8 11:09:27 还好,。liuliu24 Publish at 2005-4-22 8:11:27 很简单的东西,让你一写变复杂了218.20.53.198 Publish at 2004-7-22 18:03:01 这样截取只是对英文字母生效,,汉字是占2个字符的,如果要截取的内容是汉字加字母,要是计算出来的结果是单数..那就会显示一个奇怪的符号出来...你该改一下代码吧..yaoyj Publish at 2004-9-8 4:34:48 关于汉字被截最简单的处理方法,使用下面的函数,typess为欲显示内容,nummers为显示长度(字符长) function cuter(typess,nummers) dim types:types=typess if len(types)>nummers then cuter=left(types,nummers) & "..." else cuter=types end if end function 另一问题:如果内容中含有html标记,就不能正确显示“正文”内容了,请大家指点。221.232.168.73 Publish at 2004-7-9 14:53:45 强烈建改一下,没有写好,字毒和汉字时就难看了,误导人啊