Last active
December 16, 2015 03:59
-
-
Save danbrianwhite/cf498723b834ebd154c2 to your computer and use it in GitHub Desktop.
filePath
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
var filePath = function() | |
{ | |
//grab the path of this js file (must include name of file) | |
var _scripts = document.getElementsByTagName("script"); | |
var _pattern = /^(.*?)\/js\/filePath.js/i; | |
var _path; | |
for (var i = _scripts.length - 1; i >= 0; i--) | |
{ | |
var checkPath = _pattern.exec(_scripts[i].src); | |
if (checkPath != null) | |
{ | |
_path = checkPath[1]; | |
i = -1; | |
} | |
}; | |
var _originRegExp = new RegExp(window.location.protocol+"//"+window.location.host, "g"); | |
if(_path.match(_originRegExp) == null) | |
{ | |
_path = window.location.protocol+"//"+window.location.host + _path; | |
} | |
return _path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment