Created
February 2, 2018 11:22
-
-
Save csrui/98d06b8dc9e84e9c5babba23a3ace90a to your computer and use it in GitHub Desktop.
Get full URL using current script
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
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