Adding 'http://' to make linkable externaly

E

editor

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
 
M

McKirahan

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>"
 
A

Adrienne Boswell

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.
 
G

Giles

Response.Write "<a href='http://" & .Fields("WebAddress") &
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)
 
L

Larry Bud

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>"
 
L

Larry Bud

Larry said:
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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top