Hamburger menu highlight current page

dagnarus
6 Posts
dagnarus posted this 30 July 2024
Ask a Question

Can hamburger menu highlight current page?

Can hamburger menu highlight current page?
Vote to pay developers attention to this features or issue.
3 Replies
Order By: Standard | Newest
Support Team
Support Team posted this 30 July 2024

Alexander,

Unfortunately, no.

...................................................
Sincerely,
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Alexander, Unfortunately, no. ................................................... Sincerely, Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
dagnarus
6 Posts
dagnarus posted this 30 July 2024

I solved it by adding next script into Site Settings -> Additional Head HTML:

< script> (remove space)

    document.addEventListener('DOMContentLoaded', function() {
        // Get the current page href
        const currentPage = window.location.pathname === '/' ? './' : window.location.pathname.split('/').pop();

        // Get all navigation links
        const navLinks = document.querySelectorAll('.u-nav-item a');

        // Loop through the navigation links
        navLinks.forEach(link => {
            // Check if the href of the link matches the current page
            if (link.getAttribute('href') === currentPage) {
                // Add the active class to the matching link
                link.classList.add('active');
            }
        });
    });
</script>

by publishing I needed to change const currentPage with following code:
const currentPage = window.location.pathname === '/' ? './' : ('/' + window.location.pathname.split('/').pop());

and add following CSS:

.active {

font-weight: bold;

}

here you can change CSS how it is needed. If you want to set color, do: color: #... !important;

I solved it by adding next script into Site Settings -> Additional Head HTML: &lt; script&gt; (remove space) document.addEventListener('DOMContentLoaded', function() { // Get the current page href const currentPage = window.location.pathname === '/' ? './' : window.location.pathname.split('/').pop(); // Get all navigation links const navLinks = document.querySelectorAll('.u-nav-item a'); // Loop through the navigation links navLinks.forEach(link => { // Check if the href of the link matches the current page if (link.getAttribute('href') === currentPage) { // Add the active class to the matching link link.classList.add('active'); } }); }); </script> by publishing I needed to change const currentPage with following code: const currentPage = window.location.pathname === '/' ? './' : ('/' + window.location.pathname.split('/').pop()); and add following CSS: .active { font-weight: bold; } here you can change CSS how it is needed. If you want to set color, do: color: #... !important;

Last edited 30 July 2024 by dagnarus

Support Team
Support Team posted this 31 July 2024

Hello Alexander,

Excellent Solution!

We're glad you could make it and share it with us.

If you have any more questions or need any further assistance, feel free to ask!
We will be happy to help you at any time.

...................................................
Sincerely,
George.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hello Alexander, Excellent Solution! We're glad you could make it and share it with us. If you have any more questions or need any further assistance, feel free to ask! We will be happy to help you at any time. ................................................... Sincerely, George. Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
You must log in or register to leave comments