var location = window.location.pathname; var directoryPath = location.substring(0, location.lastIndexOf("/")+1);