I'm working with MadCap Flare, and our team currently has four websites that we are supporting. We want to be able to link these different websites together, so we've added a navigation bar that links to each separate website. The navigation bar works as intended, but we have to assign the Active tag to the correct website link in each project. We're trying to avoid these kinds solutions because manually configuring settings in each project is not our preferred way of working.
We're looking for a way to automatically detect the URL and assign an Active tag based on the URL. This doesn't seem too difficult, and I've found a lot of similar questions and solutions, but I can't seem to figure out how to do this with our current setup. Our team does not consist of coders/programmers, so we could just be missing a very easy solution.
One major challenge is the fact that the hard links, such as https://example.com/Site1/Default.htm, are default links that redirect to the site's homepage, such as https://example.com/Site1/Home.htm, so I can't even do a simple comparison between the current page and the link. Many of the solutions I've found so far seem to break down at this point.
Here's our relevant code:
HTML
<div class="my-header">
<ul class="XLink">
<li class="XLink"><a href="https://example.com/Site1/Default.htm">Site 1</a>
</li>
<li class="XLink"><a href="https://example.com/Site2/Default.htm">Site 2</a>
</li>
<li class="XLink"><a href="https://example.com/Site3/Default.htm">Site 3</a>
</li>
<li class="XLink"><a href="https://example.com/Site4/Default.htm">Site 4</a>
</li>
</ul>
</div>
CSS
ul.XLink
{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
width: 100%;
}
li.XLink
{
float: left;
}
li.XLink a
{
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li.active
{
background-color: #1c5a97;
}
/* Change the link color to #111 (black) on hover */
li.XLink a:hover
{
background-color: #111;
}
div.my-header
{
background-color: #103d78;
margin-bottom: 15px;
width: 75%;
I've tried a handful of Javascript that I've found online, but nothing has achieved what I was attempting. I've tried adding IDs to the line items, but I'm just too unfamiliar with Javascript to even know what I'm doing. Does anyone have some advice?