欢迎光临
我们一直在努力

转换字符串带有http://的超级链接字符串为真正的超级链接(源码)

建站超值云服务器,限时71元/月

//———–searched by asphouse http://aspage.yeah.net/ ————–//

//———–from http://line9.com/tek9.asp?pg=freebies&specific=34—–//

code title: auto-linking

description: how would you like to have every instance of an http:// auto-hyperlink itself to the url

address that follows it? well, here is a killer little function that will 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 is the text after it gets automatically hyperlinked to itself:

response.write "<b>text after linking:</b><br>" & vbcrlf

response.write linkurls(strunlinked)

%>

————————————————————————-

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 转换字符串带有http://的超级链接字符串为真正的超级链接(源码)
分享到: 更多 (0)