This project has moved and is read-only. For the latest updates, please go here.
Project Description
jHash allows you to work with 'location.hash' value in a similar fashion to a server-side query string.

This library utilizes the HTML5 "onhashchange" event, but also includes a fall back to still allow the change notifications to work properly in older web browsers.

Key Advantages of jHash

  • Free, open source (MIT icense)
  • Simple and Lightweight - 4kb minified / 2kb compressed
  • Supports all mainstream browsers - IE7+, Firefox, Safari, Chrome
  • Fully Documented
  • No Dependencies
  • Single Page Application support via Hash Routing
  • Hash QueryString Support for easily storing key/value pairs in hash
  • Far easier than accessing and parsing "location.hash" manually

View Documentation for full usage examples

Nuget Package

Install SQLinq via Nuget

Sample Code

// *********************************************
// jHash Routing Example:
// *********************************************
// Hash that would match this Route Pattern
// #Wisconsin/Milwaukee
    function () {
        var stateName = this.state;
        // stateName will equal 'Wisconsin'

        var cityName =;
        // cityName will equal 'Milwaukee'

// *********************************************
// "location.hash" Manipulation Examples:
// *********************************************
// URL:
// http://localhost/page.htm#SomeValue?name=Chris&location=Wisconsin

// get "root" hash value
var root = jHash.root(); // returns "SomeValue"

// get "name" hash querystring value
var name = jHash.val('name'); // returns "Chris"

// get "location" hash querystring value
var loc = jHash.val('location'); // return "Wisconsin"

// set new individual query string value
jHash.val('name', 'Steve');

// set all new query string hash values
    name: 'Steve',
    location: 'Montana'

// clear the hash

// clear just the hash root value

// clear just the hash querystring

Articles / News

2012-05-01 - jHash v2.0 Released: Now with Routing Support!
2010-11-26 - jHash: Easily Manage Browser History / window.location.hash


This project is maintained by Chris Pietschmann. He is a Microsoft MVP for Bing Maps, a Co-Founder of Carto LLC, and the Owner of Simplovation LLC a software development consulting company that specializes in Mapping/GIS related application development.

Last edited Mar 22, 2013 at 11:11 PM by crpietschmann, version 27