Hvad sker der i denne \"link\" -funktion
Jeg har problemer med denne funktion. Nogle steder laver den et dobbelt link. Altså et link i et andet link<A HREF=\"http://<A HREF=\"http://www.minside.dk\" TARGET=\"_blank\">www.minside.dk</A>\" TARGET=\"_blank\"><A HREF=\"http://www.minside.dk\" TARGET=\"_blank\">www.minside.dk</A></A><br>
Andre steder virker det. Er der nogle der kan hjælpe mig med at rette det til så der ikke er problemer med det, og evt. fortælle lidt om hvordan det fungerer?
mvh
Søren Peter
<%
Function addStyle(sInput, sTarget)
Dim sNew, sPunct, sVal1, sVal2, sVal3, sVal4,bStop
\' Define punctuation characters
sPunct = \"_-+=!?.,;:`~\'\"\"*^$%()[]{}<>|\"
\' Assign input string to local variable so we don\'t change the
\' original string.
sNew = sInput
\' Split the string by whitespace: spaces, carriage returns, line feeds,
\' and tabs. Then, for each \"word\" in the string...
For Each sVal1 in Split(sNew, \" \")
For Each sVal2 in Split(sVal1, vbcr)
For Each sVal3 in Split(sVal2, vblf)
For Each sVal4 in Split(sVal3, Chr(9))
\' Remove beginning and ending punctuation
bStop = FALSE
Do While (Not bStop)
If (Instr(sPunct, Left(sVal4, 1)) <> 0 And Len(sVal4) > 2) Then
sVal4 = Mid(sVal4, 2)
Else
bStop = TRUE
End If
Loop
bStop = FALSE
Do While (Not bStop)
If (Instr(sPunct, Right(sVal4, 1)) <> 0 And Len(sVal4) > 2) Then
sVal4 = Left(sVal4, Len(sVal4) - 1)
Else
bStop = TRUE
End If
Loop
\' If the word begins with http:// then convert all occurrences
\' of this word to a hyperlink.
If (LCase(Left(sVal4, 7) = \"http://\") Or LCase(Left(sVal4, 4) = \"www.\")) Then
If (LCase(Left(sVal4, 4) = \"www.\")) Then
If (sTarget = \"\") then
sNew = Replace(sNew, sVal4, \"<A HREF=\"\"http://\" & sVal4 & \"\"\">\" & sVal4 & \"</A>\")
Else
sNew = Replace(sNew, sVal4, \"<A HREF=\"\"http://\" & sVal4 & \"\"\" TARGET=\"\"\" & sTarget & \"\"\">\" & sVal4 & \"</A>\")
End If
Else
If (sTarget = \"\") then
sNew = Replace(sNew, sVal4, \"<A HREF=\"\"\" & sVal4 & \"\"\">\" & sVal4 & \"</A>\")
Else
sNew = Replace(sNew, sVal4, \"<A HREF=\"\"\" & sVal4 & \"\"\" TARGET=\"\"\" & sTarget & \"\"\">\" & sVal4 & \"</A>\")
End If
End If
End If
\' If this word looks like an e-mail address then convert all
\' occurrences into a mailto: link.
If (Instr(sVal4, \"@\") >= 2 And Instr(sVal4, \".\") <> 0 And Len(sVal4) >= 5) Then
sNew = Replace(sNew, sVal4, \"<A HREF=\"\"mailto:\" & sVal4 & \"\"\">\" & sVal4 & \"</A>\")
End If
Next
Next
Next
Next
\' Return converted string
addStyle = sNew
End function
%>
