I’m using the standard navbar-element in Webfow with hamburger button on mobile view. If I open the hamburger menu on the mobile and switch to another site and then use the browser’s go back button the hamburger menu at the previews page is still open.
What I’m aware of Its a standard behaviour of browser “history”, you can check it on other sites than only on clients. This has nothing to do with Webflow it is how Web API “history” works.
<script>
// Get the container element
var container = document.getElementById('nav-menu'); // replace it with the container ID which contains all the links
// Get all the link elements inside the container
var links = container.querySelectorAll('a');
// Now, 'links' is a NodeList containing all the links inside the container
// You can loop over it like this:
links.forEach(function(link) {
// Add an event listener for the click event
link.addEventListener('click', function(event) {
// Execute your custom action
document.querySelector(".w-nav-button").click(); // replace it with your hamburger menu class
});
});
</script>