Last active
August 21, 2022 16:27
-
-
Save shergin/1723959 to your computer and use it in GitHub Desktop.
resolveURL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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