现象:当在自定义函数标签中对内容进行截断时,无论你是否选了 “非解析html” ,效果都是没有解析内容中的html代码。
原因:Ks_Cls文件夹中KS_CommonCls.asp文件中gotTopic函数编写时考虑的不周全。
以下提供两种更改方式,各有利弊
第一种:
Public Function GotTopic(ByVal Str, ByVal strlen)
If Str = "" Then GotTopic = "":Exit Function
If strlen=0 Then GotTopic=Str:Exit Function
Dim l, T, c, I, strTemp
Str = Replace(Replace(Replace(Replace(Str, " ", "メ"), ""","ミ"), ">", "ぷ"), "<", "み")
l = Len(Str)
T = 0
strTemp = Str
strlen = CLng(strlen)
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
strTemp = Left(Str, I)
Exit For
End If
Next
If strTemp <> Str Then strTemp = strTemp
GotTopic = Replace(Replace(Replace(Replace(strTemp, "メ", " "),"ミ", """), "ぷ", ">"), "み", "<")
End Function
利:能准确地按给定的数字截断内容.
弊:当要截断的内容中存在 メ ミ ぷ み四个特殊字符时有可能会导致页面显示不正常.
第二种:
Public Function GotTopic(ByVal Str, ByVal strlen)
If Str = "" Then GotTopic = "":Exit Function
If strlen=0 Then GotTopic=Str:Exit Function
Dim l, T, c, I, strTemp
l = Len(Str)
T = 0
strTemp = Str
strlen = CLng(strlen)
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
strTemp = Left(Str, I)
Exit For
End If
Next
If strTemp <> Str Then strTemp = strTemp
GotTopic = strTemp
End Function
利:无论内容中包含什么字符,都能正常显示.
弊:当内容中(html代码)存在 " > <四个html标记时,不能按着指定的字数截取内容.
为了方便站长,现提供修改好的代码下载.
针对3.1版本: 第一种方式电信下载 网通下载 第二种方式电信下载 网通下载
针对3.2版本: 第一种方式电信下载 网通下载 第二种方式电信下载 网通下载
-------------------------------
易心博客站 提供网站维护 网站优化 网站制作服务 易心空间 1元2M 高速稳定