Adding 'http://' to make linkable externaly

Discussion in 'ASP General' started by editor@thecanadianexpat.com, Jan 19, 2006.

  1. Guest

    Newbie question:

    I've got an ASP that is accessing a db field populated with web
    addresses. The web addresses in the db do not have http:// as a prefix
    and as such the resulting pages do not look externaly and are dead
    links.

    How can I make the following look externally for the correct location:

    Response.Write "<a href='" & .Fields("WebAddress") &
    "'target='_blank'>" & .Fields("WebAddress") & "</a>"

    Can I get the above to automaticly add the http:// to the link?


    Thanks in advance for any advice.

    Al
     
    , Jan 19, 2006
    #1
    1. Advertising

  2. McKirahan Guest

    <> wrote in message
    news:...
    > Newbie question:
    >
    > I've got an ASP that is accessing a db field populated with web
    > addresses. The web addresses in the db do not have http:// as a prefix
    > and as such the resulting pages do not look externaly and are dead
    > links.
    >
    > How can I make the following look externally for the correct location:
    >
    > Response.Write "<a href='" & .Fields("WebAddress") &
    > "'target='_blank'>" & .Fields("WebAddress") & "</a>"
    >
    > Can I get the above to automaticly add the http:// to the link?
    >
    >
    > Thanks in advance for any advice.
    >
    > Al



    Response.Write "<a href='http://" & .Fields("WebAddress") &
    "'target='_blank'>" & .Fields("WebAddress") & "</a>"
     
    McKirahan, Jan 19, 2006
    #2
    1. Advertising

  3. Gazing into my crystal ball I observed "McKirahan" <>
    writing in news::

    >> How can I make the following look externally for the correct location:
    >>
    >> Response.Write "<a href='" & .Fields("WebAddress") &
    >> "'target='_blank'>" & .Fields("WebAddress") & "</a>"
    >>
    >> Can I get the above to automaticly add the http:// to the link?
    >>
    >>
    >> Thanks in advance for any advice.
    >>
    >> Al

    >
    >
    > Response.Write "<a href='http://" & .Fields("WebAddress") &
    > "'target='_blank'>" & .Fields("WebAddress") & "</a>"
    >


    I would highly suggest not using target=blank, it breaks the user's back
    button, and spawns a new window for each link provided. That can create
    real havoc on systems with low resources. Additionally, some pop-up
    blockers block this as well, creating yet another usabilty issue.

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Jan 22, 2006
    #3
  4. Giles Guest

    >> Response.Write "<a href='http://" & .Fields("WebAddress") &
    >> "'target='_blank'>" & .Fields("WebAddress") & "</a>"

    > "Adrienne Boswell" <> wrote
    > I would highly suggest not using target=blank,> Adrienne Boswell


    Additionally, when fixing something broken, you should check it is broken,
    or one day you may be fixing things that aren't!
    if lcase(left(.Fields("WebAddress") ,7)<>"http://" then
    sFix="http://"
    else
    sFix=""
    end if

    Response.Write "<a href='" & sFix & .Fields("WebAddress") & ">" &
    ..Fields("WebAddress") & "</a>"

    (Assuming all is http, never ftp etc)
     
    Giles, Jan 22, 2006
    #4
  5. Larry Bud Guest

    wrote:
    > Newbie question:
    >
    > I've got an ASP that is accessing a db field populated with web
    > addresses. The web addresses in the db do not have http:// as a prefix
    > and as such the resulting pages do not look externaly and are dead
    > links.
    >
    > How can I make the following look externally for the correct location:
    >
    > Response.Write "<a href='" & .Fields("WebAddress") &
    > "'target='_blank'>" & .Fields("WebAddress") & "</a>"
    >
    > Can I get the above to automaticly add the http:// to the link?


    Your problem doesn't makes any sense, as the browser will assume http
    unless the port is specified in the address. The real problem is that
    the HTML you're generated is malformed. Looks like there's no space
    between ' and target

    Response.Write "<a href='" & .Fields("WebAddress") & "'
    target='_blank'>" & .Fields("WebAddress") & "</a>"
     
    Larry Bud, Jan 24, 2006
    #5
  6. Larry Bud Guest

    Larry Bud wrote:
    > wrote:
    > > Newbie question:
    > >
    > > I've got an ASP that is accessing a db field populated with web
    > > addresses. The web addresses in the db do not have http:// as a prefix
    > > and as such the resulting pages do not look externaly and are dead
    > > links.
    > >
    > > How can I make the following look externally for the correct location:
    > >
    > > Response.Write "<a href='" & .Fields("WebAddress") &
    > > "'target='_blank'>" & .Fields("WebAddress") & "</a>"
    > >
    > > Can I get the above to automaticly add the http:// to the link?

    >
    > Your problem doesn't makes any sense, as the browser will assume http
    > unless the port is specified in the address.


    I take back what I said. If you don't specify http://, it will
    consider the address just part of the relative path.... Sorry!
     
    Larry Bud, Jan 24, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roland Gentner
    Replies:
    1
    Views:
    559
    Kevin Goodsell
    Aug 3, 2003
  2. Geoff Wedig
    Replies:
    0
    Views:
    262
    Geoff Wedig
    Jan 20, 2006
  3. Replies:
    1
    Views:
    382
    André Gillibert
    Dec 3, 2007
  4. Replies:
    1
    Views:
    362
    dorayme
    Dec 3, 2007
  5. Replies:
    1
    Views:
    154
    Dietmar Meier
    Apr 15, 2005
Loading...

Share This Page