Re: Resolving relative URLs with JavaScript
"Michel Carroll" <[email protected]> Thu, 14 Dec 2006 09:36:58 -0000
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Hi Julien, you could use location.protocol + "//" + location.hostname Michel --- In [email protected], "Julien Royer" <eldebaran@...> wrote: > > 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 >