webForumDet fria alternativet

Tiljas gäskbok

ASP

1 svar · 188 visningar · startad av fnusseweb

Medlem sedan sep. 200142 inlägg
Frågan#1

Jag har en hemsida kolla på 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]

Medlem sedan mars 20002 520 inlägg
#2

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!

www.McDz.net www.SweQuake.com

264 ms totalt · 3 externa anrop · v20260731065814-full.767b4345
121 ms — deklarationer (db)
0 ms — hämta statistik (cache)
140 ms — hämta tråd, inlägg och bilagor (db)