Jeg skulle under udarbejdelsen af Aviisi.gl bruge en funktion til at smide en <a href> på alle links i en given string. Det er kommet til at se sådan ud:
<% Function LinkURLs(strInput) Dim iCurrentLocation Dim iLinkStart Dim iLinkEnd Dim strLinkText Dim strOutput iCurrentLocation = 1 Do While InStr(iCurrentLocation, strInput, "http://", 1) <> 0 iLinkStart = InStr(iCurrentLocation, strInput, "http://", 1) iLinkEnd = InStr(iLinkStart, strInput, " ", 1) If iLinkEnd = 0 Then iLinkEnd = Len(strInput) + 1 Select Case Mid(strInput, iLinkEnd - 1, 1) Case ".", "!", "?" iLinkEnd = iLinkEnd - 1 End Select strOutput = strOutput & Mid(strInput, iCurrentLocation, iLinkStart - iCurrentLocation) strLinkText = Mid(strInput, iLinkStart, iLinkEnd - iLinkStart) strOutput = strOutput & "" & strLinkText & "" iCurrentLocation = iLinkEnd Loop strOutput = strOutput & Mid(strInput, iCurrentLocation) LinkURLs = strOutput End Function %>
Ingen kommentarer:
Send en kommentar