Du kan använda en funktion för att lösa detta...
lägg följande kod och includera den på gästboksidan denna fixar iof både länkar och textlängd kapning:
<script language=VBScript runat=Server>
Function FixLen(str,strLen)
str = Server.HTMLEncode(str)
If Len(str) > strLen Then
str=Mid(str,1,strLen-1) & "..."
End If
FixLen = str
End Function
Function FixLen2(str,strLen)
str = Server.HTMLEncode(str)
If Len(str) > strLen Then
str=LCase(str)
str=Mid(str,1,strLen-1) & "..."
End If
FixLen2 = str
End Function
Function FixSpace(str)
str = Server.HTMLEncode(str)
Dim tmpArr, i
length = 40
tmpArr = Split(str," ")
For i = 0 To UBound(tmpArr)
If Len(tmpArr(i))>length Then
If Lcase(left(tmpArr(i),4)) = "www." Then
Exit For
ElseIf Lcase(left(tmpArr(i),7)) = "http://" Then
Exit For
Elseif Lcase(left(tmpArr(i),3)) = "ftp" Then
Exit For
Else
tmpArr(i)=LCase(tmpArr(i))
tmpArr(i)=Left(tmpArr(i),length) & " "& Right(tmpArr(i), Len(tmpArr(i))-length)
If Len(tmpArr(i))>length + length Then
tmpArr(i) = FixSpace(tmpArr(i))
End If
End If
End If
Next
str=""
For i = 0 To UBound(tmpArr)
str = str & tmpArr(i) & " "
Next
FixSpace = str
End Function
Function FixLink(strText)
'strText = Server.HTMLEncode(strText)
strText = Replace(strText,VbCrLf,VbCrLf&" <br> ")
HyperArray = Split(strText)
For Each ord in HyperArray
if Len(ord) > 7 then
ord2 = ord
if Lcase(left(ord,7)) = "http://" then
strText2=strText2 & "<a href='"&ord&"' target=""_blank"">"&FixLen2(ord2,40)&"</a> "
elseif InStr(ord,"@")>1 then
strText2=strText2 & "<a href='mailto:"&ord&"'>"&FixLen2(ord2,40)&"</a> "
elseif Lcase(left(ord,4)) = "www." then
strText2=strText2 & "<a href='http://"&ord&"' target=""_blank"">"&FixLen2(ord2,40)&"</a> "
else
strText2=strText2&ord&" "
end if
else
strText2=strText2&ord&" "
end if
next
FixLink = strText2
End Function
</script>
Sen anropar du funktionen där texten skrivs ut så här:
<%=FixSpace(Rs("blabla"))%>
------------------
McD- Burgers for the people!
