If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

hyperlink points to my root address when http is omitted

Code:

<a href='www.test.com'>test</a>

I was creating a hyperlink when I noticed that it pointed to http://www.mysite.com/test.com instead. I thought there might be something wrong with my formatting scripts, but it turns out it was because I was missing the http portion of the url.

Before I update my formatting script to auto correct and add the http if it is missing I was wondering why this was happening.

www.whatever.com is not a valid href, not in the sense in which it is obviously intended. It's interpreted as a file or folder name (either of which may contain . characters), and like any relative path is prepended automatically with the path to the current page.

If you want it to go to www.whatever.com, then the proper href to use is:

http://www.whatever.com/

Or:

https://www.whatever.com

Or even:

//www.whatever.com

In which case the browser will take the protocol of the current page (http: or https: or even file: if it's a local page not on a server, which is why this syntax is not used more often) and prepend that to it. This can be handy though if you have a template that is used by both http and https pages on your site and you want your off site link(s) to go to the corresponding type of layer on the external site, assuming they have both.