源代码
function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&"..."
elsecutstr=tempstr
end if
end function%>
调用方法
<%=cutstr(rs_news("title"),18)%>
function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&"..."
elsecutstr=tempstr
end if
end function%>
调用方法
<%=cutstr(rs_news("title"),18)%>
本文介绍了一个VBScript中的自定义函数cutstr,用于实现对过长字符串的智能截取,并在末尾添加省略号以提示用户内容已被缩减。该函数接受两个参数:待处理的字符串及目标长度。当输入字符串长度超过指定长度时,将只保留前段内容并附加省略号;若原始字符串长度未超出限制,则直接返回原字符串。
1634

被折叠的 条评论
为什么被折叠?



