SyntaxFix
Write A Post
Hire A Developer
Questions
This will work for actual paths on the file system if you're not talking the URL string.
var path = document.location.pathname; var directory = path.substring(path.indexOf('/'), path.lastIndexOf('/'));