Anchor

Anchor is a native javascript plugin that enables developers to take back control of their anchor links. From allowing them to pass parameters using the familer syntax to binding events to happen when those anchor links are viewed.

Please note that this is pre-release sofware and does not reflect the final quality of the product as it may contain bugs, be missing features and have other problems.

Getting started

Getting started with Anchor couldn't be easier, all it requires is to include the script in your head link so...

<script type="text/javascript" src="anchor.js"></script>  

And then initialise Anchor with this line of code...

var anchor = new Anchor();  

You can also set global options to override the default behaviour of Anchor. These can be passed in to the initializer as an object. The options available are as follows...

Setting Type Default Description
debugger boolean false Enables/disables the debugger.
silenced boolean false Enables/disables the functions being immediatly executed on the hashchange event.

Get

Get the current anchor link.

anchor.get();  

Set

Set the current anchor link.

anchor.set(anchor, parameters, silenced);  
Parameter Type Default Description
anchor string undefined The anchor you wish to set.
parameters array undefined The parameters you wish to send with the anchor.

On

Create an event to respond to a certain anchor.

anchor.on(anchor, event);  
Parameter Type Default Description
anchor string undefined The anchor you wish to interact with.
event function undefined The event you want to occur when the anchor is visited.

This function supports multple events, to create more simply chain call this function or call it again with the same anchor and it will be queued.

Download