| 网站首页 | 硬件维修 | 应用学院 | 网络组建 | 网站制作 | 菜鸟黑客 | 编程之道 | 数码大全 | 娱乐休闲 | 软件下载 | 在线视频 | 请您留言 | 技术论坛 | 
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • HTML页面如何象asp一样接受参…

  • 一个简单的javascript菜…

  • 一个很通用的javascript…

  • 限制图片上传长宽的java…

  • 实现textarea内字符串选择查…

  • 一行代码生成Google SiteMap

  • 几行代码轻松搞定网页的简繁…

  • HTML语言剖析(八)表单标记

  • HTML语言剖析(七)表格标记

  • 为什么要抛弃HTML

  • Q
    您现在的位置: 我是IT人 >> 网站制作 >> ASP >> 文章正文
    转换字符串带有http://的超级链接字符串为真正的超级链接         
    转换字符串带有http://的超级链接字符串为真正的超级链接
    作者:网络 文章来源:转载 点击数: 更新时间:2005-9-30
    [ 字体:缩小 正常 放大 | 双击自动滚屏 ]
    请选择合适的字体颜色:


    //-----------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)
    %>
    -------------------------------------------------------------------------

    [1] [2] 下一页  

    文章录入:小秦    责任编辑:小秦 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |