Re: Re: Resolving relative URLs with JavaScript
"Julien Royer" <[email protected]> Thu, 14 Dec 2006 11:07:08 +0100
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Hi Michel,
Thank you for your answer.
I'm looking for a solution which enables to get exactly the same
result as the one given by the URL resolve engine of the browser (even
if the URL starts with "../", for example).
But in fact, it seems that the following code works on IE 5+, FF 1.5
and Opera 9 :
function solveURL(url) {
var img = document.createElement("img");
img.src = url;
return img.src;
}
I don't understand why IE resolves the image URL and not the link URL...
Julien
On 12/14/06, Michel Carroll <[email protected]> wrote:
> Hi Julien,
>
> you could use location.protocol + "//" + location.hostname
>
> Michel