Created
July 11, 2012 01:43
-
-
Save qhm123/3087415 to your computer and use it in GitHub Desktop.
js relative path to absolute
This file contains 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
// If it's a relative path, we need to make it absolute, using the | |
// reader's location (not the active component's location). | |
if (!url.match(/^\//)) { | |
var link = document.createElement('a'); | |
link.setAttribute('href', url); | |
url = link.href; | |
delete(link); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment