Convert string with http://hyperlink string for true hyperlink (source)

Source: Internet
Author: User
link | convert | string//-----------searched by Asphouse http://aspage.yeah.net/--------------//
-----------from http://line9.com/tek9.asp?pg=freebies&specific=34-----//
Code title:auto-linking
Description:how would to have every instance of a http://auto-hyperlink to the URL
Address that follows it? We are a killer little function that would take every one of those that it
Finds in a string and sets up the hyperlink for you! Cool, eh?
Copy and paste this snippet As-is into your editor:

-------------------------------------------------------------------------
<%
Function Linkurls (strinput)
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 & "<a href=" "&strLinkText&" ">" &strLinkText& "</a>"
Icurrentlocation = Ilinkend
Loop
Stroutput = stroutput & Mid (strinput, icurrentlocation)
Linkurls = Stroutput
End Function
strunlinked = "Http://LINE9.com rules! <br> "& VbCrLf
strunlinked = strunlinked & "Http://pdxpc.com sells great computers!<br>" & VbCrLf

' Here is the before text:
Response.Write "<b>original text:</b><br>" & vbCrLf
Response.Write strunlinked
Response.Write VbCrLf & "<br>" & VbCrLf & VbCrLf

' Here's the text after it gets automatically hyperlinked to itself:
Response.Write "<b>text after Linking:</b><br>" & VbCrLf
Response.Write Linkurls (strunlinked)
%>
-------------------------------------------------------------------------



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.