Created
February 28, 2017 00:21
-
-
Save catichenor/627ff6450b031114abe13201b7062d6c to your computer and use it in GitHub Desktop.
Change relative URL to absolute URL in Javascript
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
| // Adapted from https://muaz-khan.blogspot.com/2012/02/absolute-or-relative-url-issues-and.html | |
| function qualifyURL(url) { | |
| var a = document.createElement('a'); | |
| a.href = url; // set string url | |
| url = a.href; // get qualified/absolute url | |
| a.href = null; // no server request | |
| return url; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment