Prototyping Navigation with JavaScript
Anthony Dillon
on 24 August 2012
Tags: Design
I wondered if I could make an easily updateable, prototype site in order to test a number of different IA’s using an XML file to represent the sitemap. This post is about what I did and how to get some sample code if you want to use or extend it for yourself.
The XML
The goal is to be able to simply edit, delete or add a section in the XML and refresh the site. There you have it. The navigation menu has changed.
Each <page> child of <sitemap> is top level navigation. You add children to that by placing <page> nodes inside each other.
<page title="Contact" url="contact-me">
- title – The name of the menu item and the title of the page
- url – The permalink for that page, this is added to the parents name if a child
Below is an example navigation to build a personal website:
<sitemap> <page title="Work" url="work"> <page title="Develop" url="develop"> <page title="Web development" url="web-development"></page> <page title="Apps" url="apps"></page> </page> <page title="Design" url="design"> <page title="Web design" url="web-design"></page> <page title="Magazines" url="magazines"></page> <page title="Cartoons" url="cartoons"></page> </page> <page title="Videos" url="videos"> <page title="Animation" url="animation"></page> <page title="Live footage" url="live-footage"></page> <page title="Showreel" url="showreel"></page> </page> </page> <page title="About Me" url="about-me"> <page title="Life" url="life"> <page title="Photos" url="photos"></page> <page title="Videos" url="videos"></page> <page title="Inspiration" url="inspiration"></page> </page> <page title="Socal" url="social"> <page title="Friends" url="friends"></page> <page title="Family" url="family"></page> <page title="Things I've done" url="done"></page> <page title="Bucket list" url="bucket-list"></page> </page> </page> <page title="Contact" url="contact-me"></page> </sitemap>
The system has only been developed to navigate three levels deep.
Adverts
I also wanted to have little ads in the corner of some of the mega menu dropdowns. To do this, there is an promo.xml in the XML folder. Simply wrap a title, img, p and link, if you would like, in the url of the top level link. This will result in an advert style banner on the right side of the menu. You can restyle this banner with CSS.
Here is the example of promo.xml:
<adverts> <work> <title>Latest website</title> <img>assets/images/200x150-b8b8b8-fff.jpg</img> <link url="#work/develop/web-development">See more</link> </work> <about-me> <title>My picture</title> <img>assets/images//200x150-b8b8b8-fff.jpg</img> <p>This is a little blarb all about what I do and where I am.</p> </about-me> </adverts>
This is a little blarb all about what I do and where I am.
Hash bang
Using hash bangs, the site does not reload the page when a menu item is clicked. The JavaScript takes the updated hash value and updates the page values to mimic a new page. There are even three different page contents that are changed to reinforce to the user the fact we have changed page.
Demo
Check out the demo: http://www.anthonydillon.com/navigation-prototyping
The Result
The results were good. We were able to use this code to test three potential IAs and the mega menu itself with ten users. The XML allowed the me to easily tweak the menus between tests and it looked real enough that the users weren’t distracted by the lack of content behind the pages.
The Code
Feel free to use the code for quick navigation prototyping at: https://launchpad.net/navigation-prototyping
If you would like contribute to this project all your help is appreciated!
Talk to us today
Interested in running Ubuntu in your organisation?
Newsletter signup
Related posts
Visual Testing: GitHub Actions Migration & Test Optimisation
What is Visual Testing? Visual testing analyses the visual appearance of a user interface. Snapshots of pages are taken to create a “baseline”, or the current...
Let’s talk open design
Why aren’t there more design contributions in open source? Help us find out!
Canonical’s recipe for High Performance Computing
In essence, High Performance Computing (HPC) is quite simple. Speed and scale. In practice, the concept is quite complex and hard to achieve. It is not...