Skip to content

Instantly share code, notes, and snippets.

@mikesprague
Last active December 25, 2015 11:47
Show Gist options
  • Save mikesprague/5706268 to your computer and use it in GitHub Desktop.
Save mikesprague/5706268 to your computer and use it in GitHub Desktop.
JavaScript: getRootWebSitePath
function getRootWebSitePath() {
var _location = document.location.toString();
var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3);
var applicationName = _location.substring(0, applicationNameIndex) + '/';
var webFolderIndex = _location.indexOf('/', _
location.indexOf(applicationName) + applicationName.length);
var webFolderFullPath = _location.substring(0, webFolderIndex);
return webFolderFullPath;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment