Skip to content

Instantly share code, notes, and snippets.

@qhm123
Created July 11, 2012 01:43
Show Gist options
  • Save qhm123/3087415 to your computer and use it in GitHub Desktop.
Save qhm123/3087415 to your computer and use it in GitHub Desktop.
js relative path to absolute
// 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