I\'m trying to add a \"back to dir\" button at the top of a web page, which would redirect the user to the same URL, but with no filename in it.
For example, clickin
/* to avoid query parameters, use pathname instead of href */ var l = document.location.pathname.split('/'); l.pop(); console.log(document.location.origin + l.join('/'));