蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

(asp)过长字符截取问题

        代码如下,总是说if (len(contentw)>5){这一行不错

<% var contentw=(Recordset1.Fields.Item("yqwww").Value)
        if (len(contentw)>5){
                contentw=left(contentw,6)
                Response.Write(contentw+"...")
                }
                        else
                {
                Response.Write(contentw)
}
%>


Microsoft JScript 运行时错误 错误 '800a138f'

缺少对象

/warpm/5.asp,行32

你用我这个,把下面这个插入页面
[code]
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoTrimProperly(str, nNamedFormat, properly, pointed, points)
  dim strRet
  strRet = Server.HTMLEncode(str)
  strRet = replace(strRet, vbcrlf,"")
  strRet = replace(strRet, vbtab,"")
  If (LEN(strRet) > nNamedFormat) Then
    strRet = LEFT(strRet, nNamedFormat)
    If (properly = 1) Then
      Dim TempArray
      TempArray = split(strRet, " ")
      Dim n
      strRet = ""
      for n = 0 to Ubound(TempArray) - 1
        strRet = strRet & " " & TempArray(n)
      next
    End If
    If (pointed = 1) Then
      strRet = strRet & points
    End If
  End If
  DoTrimProperly = strRet
End Function
</SCRIPT>
[/code]

然后调用,比如:<%=DoTrimProperly(rs("title"), 10, 0, 1, "…")%>
这里rs("title")是数据字段,10是截取多少个字符

谢谢!!!

你后面的几个参数是什么意思啊,能说明一下吗?
感觉写得很好!但看得不是很明白!

properly, pointed, points 这几个!




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com