3 ms·
We've (the boomerang dev team) seen many frameworks do this. For many parts of boomerang, we need to get the url of an object (img, a, iframe, anything that cou
by bluesmoon 8y ago
We've (the boomerang dev team) seen many frameworks do this. For many parts of boomerang, we need to get the url of an object (img, a, iframe, anything that could have a url), and just looking at the object's `src`/`currentSrc` or `href` attributes is insufficient.
What we need to do is create a new `link` element, attach it to the window, assign the url to the link's `href` attribute, and then read that attribute back out. This process converts all relative URLs to absolute URLs, taking BASE into consideration.
Note, that you MUST add the link to the document of the correct window. Adding it to the document of an anonymous iframe will not work because while anonymous iframes inherit a lot of things from the parent, the baseURI isn't one of them.