asp 中div显示超过一定字数 显示省略号
如下<divclass="listbox"><divclass="title"><h3>最近更新</h3><spanclass="more"><ahref="inform...
如下
<div class="listbox">
<div class="title">
<h3>最近更新</h3>
<span class="more"><a href="information.asp" target="_blank" title="更多…"><img src="img/more.gif"/></a></span></div>
<ul class="ul1">
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "select top 19 * from Message order by ID desc "
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 800
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
<li><%=Recordset1.Fields.Item("Title").Value%></li>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
<% End If %>
</ul>
</div>
页面显示效果
我想做到这样 每一条信息的字数超过10个字后面就显示省略号,类似如下效果
请问各位,该怎么写??? 展开
<div class="listbox">
<div class="title">
<h3>最近更新</h3>
<span class="more"><a href="information.asp" target="_blank" title="更多…"><img src="img/more.gif"/></a></span></div>
<ul class="ul1">
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "select top 19 * from Message order by ID desc "
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 800
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))%>
<li><%=Recordset1.Fields.Item("Title").Value%></li>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
<% End If %>
</ul>
</div>
页面显示效果
我想做到这样 每一条信息的字数超过10个字后面就显示省略号,类似如下效果
请问各位,该怎么写??? 展开
2个回答
展开全部
不需要那么麻烦:
这一句:
<%=Recordset1.Fields.Item("Title").Value%>
改成:
<%=left(Recordset1.Fields.Item("Title").Value,15)%>...
其中15为需要显示的长度
这样做的话,不到15的后面也显示省略号,可以自己做个判断
if len("title")<15 Then
直接显示
<%=Recordset1.Fields.Item("Title").Value%>
else
<%=left(Recordset1.Fields.Item("Title").Value,15)%>...
End If
这一句:
<%=Recordset1.Fields.Item("Title").Value%>
改成:
<%=left(Recordset1.Fields.Item("Title").Value,15)%>...
其中15为需要显示的长度
这样做的话,不到15的后面也显示省略号,可以自己做个判断
if len("title")<15 Then
直接显示
<%=Recordset1.Fields.Item("Title").Value%>
else
<%=left(Recordset1.Fields.Item("Title").Value,15)%>...
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以用一个函数实现:
function cutLength(str,length)
str=trim(str)
str=replace(str," "," ")
str=replace(str,"<br>","")
str=replace(str,""","""")
if len(str)>length then
str=left(str,(length-3))&"..."
end if
cutLength=str
end function
用法:<%=cutlength(str,10)%>
function cutLength(str,length)
str=trim(str)
str=replace(str," "," ")
str=replace(str,"<br>","")
str=replace(str,""","""")
if len(str)>length then
str=left(str,(length-3))&"..."
end if
cutLength=str
end function
用法:<%=cutlength(str,10)%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询