Whilst working on a recent project, I wanted an accordion navigation to remain open depending on what the category segment in the url was displaying. To do this I found a simple bit of JavaScript published on CSS-Tricks which looks like this:
Get the full URL path:
var newURL = window.location.protocol + "://" + window.location.host + "/" + window.location.pathname;
Next split the segments of the URL using: