MyBB Community Forums

Full Version: Template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

Anybody know any methods to adding a class to the nav bar for each specific page (once selected)? Like above on the MyBB site nav bar.

Example:
Contact page =
<li class="current"><a href="contact.html" title="">Contact us</a></li>

(if you understand..)
Not 100% sure on a fix, but you might get better support here:
http://community.mybb.com/forum-10.html
You can use a javascript on-click function to set the target class active. Its that simple.
Somebody shared the code here before, forgot who ...

Quote:function setActive() {
aObj = document.getElementById('nav').getElementsByTagName('a');
for(i=0;i<aObj.length;i++) {
if(document.location.href.indexOf(aObj[i].href)>=0) {
aObj[i].className='active';
}
}
}
(2012-09-22, 01:25 PM)effone Wrote: [ -> ]You can use a javascript on-click function to set the target class active. Its that simple.
Somebody shared the code here before, forgot who ...

Quote:function setActive() {
aObj = document.getElementById('nav').getElementsByTagName('a');
for(i=0;i<aObj.length;i++) {
if(document.location.href.indexOf(aObj[i].href)>=0) {
aObj[i].className='active';
}
}
}

What would be the way to implement that? is it onClick="javascript:setActive" ??
onclick="setActive()"
It's not really what I'm after because it wont save when i load a open a new page.