Highlight link to current page with javascript

If you have a menu on your website and you would like to provide some visual feedback with that one of the links in the menu bar is the page you are on it’s pretty easy with some HTML and CSS.

All you have to do is add a class name to the HTML for that link and then style that class name with CSS.

For example just style the class of “current”:

<li class="current"><a href="http://www.somepage.com">some page</a></li> 

Unfortunately if you are using a common navigation system where you have one file that has all the navigation elements linked to hundreds of pages it’s not possible to change the link style for every link. It defeats the purpose of a common shared file.

Thankfully I found an old blog post by Jonathan Snook that had a script that worked perfectly to strip the link from the current page button. See how “Drama Club” in this screen shot is now light gray and slightly out-dented? It is now an inactive link so if you hover your mouse over it the cursor will not change.

Screen Shot 2015-02-04 at 4.11.16 PM

All you need to make this work is a link to your JS file in your HTML document in the head section like this

<script type=”text/javascriptsrc=”clearlink.js“></script>

Then in the JS file this is the below content is all you need. After that the rest is styling with CSS!

/*
CLCP v2.1 Clear Links to Current Page
Jonathan Snook
This code is offered unto the public domain
http://www.snook.ca/jonathan/
*/

window.onload = clearCurrentLink;

function clearCurrentLink(){
    var a = document.getElementsByTagName("A");
    for(var i=0;i<a.length;i++)
        if(a[i].href == window.location.href.split("#")[0])
            removeNode(a[i]);
}

function removeNode(n){
    if(n.hasChildNodes())
        for(var i=0;i<n.childNodes.length;i++)
            n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
    n.parentNode.removeChild(n);
}

Pet website in progress

Here is a website I’ve been working on.

Below is a screenshot of the home page mockup and one support page along with a rough logo composition. The idea of the site is to pair breeders and buyers with dogs that make good companion pets. Not all shelter dogs fit this description and there is still a need for breeders than breed for certain temperaments that will make a good companion. Through user feedback and a strict set up rules for breeders the idea is to ensure quality in the puppies that are listed here. Beta version of the website here.

 

sc1 Read more

Design process for building an interactive map

Design process for building an interactive map

This isn’t really a tutorial of how to create an interactive map as this blog post would be way too long and too complex. It’s more about the process of taking various resources and putting them together to create something. As I write this post this map is a work in progress. View Demo

The first step was to create the map. This was mostly done taking a screen grab from a satellite view of our campus off of Google maps. Then the buildings were traced using the pen too for each panel and curve. Shading was applied to give the buildings a 3D look.

header

For masthead where the text looks like chalkboard type I used the rough texture of paper overlay into white type. I then outlined the type and the arrow that I drew with a rough brush.

The map below is using several different technologies.

  • Image maps to make hot regions using Adobe Dreamweaver to define the coordinates on mouse hover.

map1 Read more