开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术客户端相关 → 转换字符串带有http://的超级链接字符串为真正的超级链接(源码)
转换字符串带有http://的超级链接字符串为真正的超级链接(源码)
日期:2000年10月28日 作者: 人气:     [ ]
//-----------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)
%>
-------------------------------------------------------------------------

(出处:)

相关文章:
 
·SQL Server 2000 SP4发布
·Sql Server 2005最新CTP简介及截图
·微软发布数据库新测试版 最终版明夏登场
·网络社区论坛即将成为互联网下一热点
·SET NOCOUNT的用法和注意事项
·全正则的检测IP是否合法的函数
·判断一个access数据库中某个表是否存在的方法
·用Asp生成条形码
·数字小写到英文大写的转换
·在不支持FSO的服务器上使用XMLDOM创建HTML文件
相关软件:
 
·拓域会员核心系统 v1.02
·深博贴吧(仿百度)双数据库版 v1.5
·通用草稿自动保存系统SipoAutoSaver v2.0
·BJXSHOP网上开店专家 v6.0 SP1 Build 20060118
·企业网站智能管理系统(TZIMS) v1.5
·bzmtv v1.0 正式版
·宜兴二级域名申请系统SQL版
·Mslove交友系统 v3.0
·亿人通讯录 v3.0
·深博贴吧(仿百度)双数据库版 v1.0
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077