Skip to content

Instantly share code, notes, and snippets.

@shergin
Last active August 21, 2022 16:27
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shergin/1723959 to your computer and use it in GitHub Desktop.
Save shergin/1723959 to your computer and use it in GitHub Desktop.
resolveURL
function resolveURL(baseURL, relativeURL) {
var html = document.implementation.createHTMLDocument("");
var base = html.createElement("base");
base.setAttribute("href", baseURL);
var a = html.createElement("a");
a.setAttribute("href", relativeURL);
html.head.appendChild(base);
html.body.appendChild(a);
return a.href;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment