Resolving relative URLs with JavaScript

"Julien Royer" <[email protected]> Wed, 13 Dec 2006 22:43:46 +0100
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
Hello,

I am wondering if there is a DOM method which enables to access the
URL resolve engine of the underlying browser. I tried the following
solution :

var a = document.createElement("a");
a.href = "ho-ho-ho/";
alert(a.href);

It works properly on FF 1.5 and Opera 9 (returns for example
"http://example.com/ho-ho-ho/"), but IE just returns the original
string.

I would like to avoid a handmade solution, as it would be quite boring
to test all the possible cases (use of the <base> tag for exemple).
Furthermore, I find it paradoxal not to be able to do that as the
JavaScript is running in a Web browser...

Thank you by advance for your answers !

Julien