Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:25:49+00:00 2026-06-05T21:25:49+00:00

Last week I created an e-shop with opencart. Now I’m trying to customize the

  • 0

Last week I created an e-shop with opencart. Now I’m trying to customize the default top menu. What I want to do is to keep the parent highlighted even when a child element is selected

I highlight the current page with this js :

    <script type="text/javascript" >
function extractPageName(hrefString)
{
    var arr = hrefString.split('/');
    return  (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}

function setActiveMenu(arr, crtPage)
{
    for (var i=0; i < arr.length; i++)
    {
        if(extractPageName(arr[i].href) == crtPage)
        {
            if (arr[i].parentNode.tagName != "DIV")
            {
                arr[i].className = "current";
                arr[i].parentNode.className = "current";
            }
        }
    }
}

function setPage()
{
    hrefString = document.location.href ? document.location.href :document.location ;

    if (document.getElementById("menu") !=null)
    setActiveMenu(document.getElementById("menu").getElementsByTagName("a"),extractPageName(hrefString));
}


window.onload=function()
{
    setPage();
}

</script>

Any help would be greatly appreciated.

p.s. sorry for my English, if you can’t understand what I want to make.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:25:50+00:00Added an answer on June 5, 2026 at 9:25 pm

    I figured it out. Tooraj gives me the idea. Here is my code :

    <script type="text/javascript" >
    function extractPageName(hrefString)
    {
        var arr = hrefString.split('/');
        return  (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
    }
    
    function setActiveMenu(arr, crtPage)
    {
        for (var i=0; i < arr.length; i++)
        {
            if(extractPageName(arr[i].href) == crtPage)
            {
                if (arr[i].parentNode.parentNode.parentNode.parentNode.tagName != "DIV",
                arr[i].parentNode.tagName != "DIV")
                {
                    arr[i].className = "current";               
    
                    arr[i].parentNode.parentNode.parentNode.parentNode.className = "current";
                                    arr[i].parentNode= "current";
                }
            }
        }
    }
    
    function setPage()
    {
        hrefString = document.location.href ? document.location.href :document.location ;
    
        if (document.getElementById("menu") !=null)
        setActiveMenu(document.getElementById("menu").getElementsByTagName("a"),extractPageName(hrefString));
    
    }
    
    
    
    
    
    window.onload=function()
    {
        setPage();
    }
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying for the last week to find a way to make
In the last week I've created two classes which my team expressed some concerns
I have a set of records that were created last week, and from those
Last week, we created a program that manages sets of strings, using classes and
I have been trying to wrap my head around mvvm for the last week
I created a simple function to get first and last day of a week
I am working on NetBeans 7.0 which has maven 3.0.3 by default.... last week
I have started Gwt last week. And I was trying to create application without
The last week I stumbled over this paper where the authors mention on the
I've spent the last week developing code to connect to a Web Service using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.