<%
Function makeLinks(inText)
Dim objRegExp, strBuf
Dim objMatches, objMatch
Dim Value, ReplaceValue, iStart, iEnd
strBuf = ""
iStart = 1
iEnd = 1
Set objRegExp = New RegExp
objRegExp.Pattern = "\b(www|http|\S+@)\S+\b"
objRegExp.IgnoreCase = True
objRegExp.Global = True
Set objMatches = objRegExp.Execute(inText)
For Each objMatch in objMatches
iEnd = objMatch.FirstIndex
strBuf = strBuf & Mid(inText, iStart, iEnd-iStart+1)
If InStr(1, objMatch.Value, "@") Then
strBuf = strBuf & GetHref(objMatch.Value, "EMAIL", "_BLANK")
Else
strBuf = strBuf & GetHref(objMatch.Value, "WEB", "_BLANK")
End If
iStart = iEnd+objMatch.Length+1
Next
strBuf = strBuf & Mid(inText, iStart)
makeLinks = strBuf
End Function
Function GetHref(url, urlType, Target)
Dim strBuf
strBuf = "<a href="""
If UCase(urlType) = "WEB" Then
If LCase(Left(url, 3)) = "www" Then
strBuf = "<a href=""
http://" & url & """ Target=""" & _
Target & """>" & url & "</a>"
Else
strBuf = "<a href=""" & url & """ Target=""" & _
Target & """>" & url & "</a>"
End If
ElseIf UCase(urlType) = "EMAIL" Then
strBuf = "<a href=""mailto:" & url & """ Target=""" & _
Target & """>" & url & "</a>"
End If
GetHref = strBuf
End Function
%>
<%
Response.Buffer = True
Set Con = Server.CreateObject("ADODB.Connection")
DBPath = "DBQ=" & server.mappath("news.mdb")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath
Sql = "SELECT * FROM News ORDER BY date1 DESC"
Set Record = Con.Execute(Sql)
%>
<title> [ designforlife ] | graphic design </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="kristian, kruse, lehn, web, internet, design, grafisk, logo, banner, adobe, photoshop, it">
<meta name="description" content=" [ designforlife ] is a site about graphic design.">
<meta name="author" content=" [ designforlife ] ">
<meta name="robots" content="all">
<link rel="shortcut icon" href="
http://www.designforlife.dk/favicon.ico"><link rel="stylesheet" href="../../files/dfl.css" type="text/css">
<script language="JavaScript1.2" type="text/javascript" src="../../files/dfl.js"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table border="0" cellspacing="0" width="650">
<tr>
<td align="center" colspan="2">
<h1>News</h1>
</td>
</tr>
<% Do While Not Record.EOF %>
<tr>
<td height="20" width="400">
<div align="left">
<% Response.Write Record("News") %>
</div>
</td>
<td height="20" width="250">
<div align="right">
<% Response.Write Record("Date1") %>
|<i>
<% Response.Write Record("Writer") %>
</i>
<br><b>
<% Response.Write Record("Mail") %>
</b>
</div>
</td>
</tr>
<tr>
<td height="10" colspan="2"><img src="../../img/hr.gif" border="0"></td>
</tr>
<%
Record.MoveNext
Loop
%>
</table>
<br>
<input type="button" name="Submit" value="Add news" class="submit" onclick="location.href='../news.asp'">
</body>
</html>
<%
Con.Close
Set Con = Nothing
%>
Hvor skal jeg sætte <%=makeLinks("Tekst hvor adresser skal gøres klikbare")%> ind, når jeg vil hive links ud af mail og news....?