When I am using a <a href="examplesite.org" target="_blank">
if I click the link I am taken to currentsite/examplesite.org.
If I then change this to <a href="http://www.examplesite.org" target="_blank">
I am taken to the correct site.
As these links are data driven (pulled from a URLs table in my Database) I would rather not have to either:
Any advice?
I suspect you could prepend //
to each URL in your HTML:
<a href="//examplesite.org" target="_blank">
This will make the link relative to the current page’s protocol (i.e. http or https), but will otherwise make the href
value be treated as a domain name.
Of course, this assumes that the link’s href
value will always be intended as a domain. It’s difficult to differentiate an href
intended as a domain (e.g. examplesite.org) from one intended as a relative page link on your site (e.g. examplepage.html), especially now that top-level domains have gone insane.