Skip to main content

Alright there is no debate includes are the best way to code a nav right? Well, what if someone wants to indicate to the use what page they’re on?  Or as I will call it the active page. Just include a script to the top of each page comparing strings with the window location, and if its true; make it look like the active page. I’m horrible with words but hopefully this is making sense. Now I’ll let the code speak: 

var contact = RegExp("contact");
if(contact.test(window.location) == true)
{
$('home').addClass('active');
}

Nothing to complex- Just comparing our variable string of contact and comparing it with the window location. If there is a match then you attach an “.active” class to it. I know its nothing big; but a simple trick helps every now and again.

One Comment

  • var adobe = compete(macromedia) {
    return "error: cannot compete against flash";
    }else{
    run solution($buymacromedia){
    echo "Introducing Adobe Flash";
    }
    //remember to overcharge for suite now that it is adobe
    //remember to be inconsistent with ctrl-Z through all adobe programs
    }