---
title: "Tiljas gäskbok"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/11528-tiljas-gäskbok"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "fnusseweb"
published: "2001-09-09T17:35:00.000Z"
updated: "2001-09-09T18:18:00.000Z"
replies: 1
views: 194
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/11528-tiljas-gäskbok"
---

# Tiljas gäskbok

## #1 — fnusseweb, 2001-09-09T17:35Z

Jag har en hemsida kolla på [www.zurr.dot.nu](http://www.zurr.dot.nu)  (En klass sida)
\-------------------------------------
Gästboken på sidan är bra som den är men, om du använder mer en 15 tecken på en rad så blir det fult i framen.
\--------------------------------------
Så jag undrar om det finns nån som vet en kod som gör att texten automatiskt byter rad efter 15 tecken

PS. sidan är inte klar en

\[Redigerat av fnusseweb den 09 sep 2001\]

Permalänk: https://www.webforum.nu/p/11528

## #2 — McD, 2001-09-09T18:18Z

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"))%>
```

Permalänk: https://www.webforum.nu/p/286024

---

Tråden på webben: https://www.webforum.nu/amne/asp/11528-tiljas-gäskbok
