Skip to content

Instantly share code, notes, and snippets.

@csrui
Created February 2, 2018 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csrui/98d06b8dc9e84e9c5babba23a3ace90a to your computer and use it in GitHub Desktop.
Save csrui/98d06b8dc9e84e9c5babba23a3ace90a to your computer and use it in GitHub Desktop.
Get full URL using current script
var plgPath = function(){
var path = null, currentScript = null;
var scripts = document.getElementsByTagName("script");
for(var i in scripts){
if(scripts[i].src.indexOf("script.js") >= 0){
currentScript = scripts[i];
break;
}
}
path = currentScript.src.substring(0, currentScript.src.lastIndexOf("/") + 1);
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment