https://github.com/crpietschmann/jhash
jHash allows you to work with 'location.hash' value in a similar fashion to a server-side query string. It also supports cross-browser "hashchange" event handling and a hash-based Routing engine.
https://github.com/crpietschmann/jhash
hash jquery querystring router
Last synced: 9 months ago
JSON representation
jHash allows you to work with 'location.hash' value in a similar fashion to a server-side query string. It also supports cross-browser "hashchange" event handling and a hash-based Routing engine.
- Host: GitHub
- URL: https://github.com/crpietschmann/jhash
- Owner: crpietschmann
- License: mit
- Created: 2017-09-01T01:49:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-15T22:41:59.000Z (over 2 years ago)
- Last Synced: 2025-04-09T18:16:23.235Z (9 months ago)
- Topics: hash, jquery, querystring, router
- Language: JavaScript
- Size: 1.53 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# jHash - "location.hash" -based Routes and Querystrings
jHash allows you to work with 'location.hash' value in a similar fashion to a server-side query string. It also supports cross-browser "hashchange" event handling and a hash-based Routing engine.
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.
[View Documentation Here](https://github.com/crpietschmann/jHash/wiki)
## 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
## NuGet Package
[http://nuget.org/packages/jhash](http://nuget.org/packages/jhash)

## Sample Code
```
// *********************************************
// jHash Routing Example:
// *********************************************
// Hash that would match this Route Pattern
// #Wisconsin/Milwaukee
jHash.route('{state}/{city}',
function () {
var stateName = this.state;
// stateName will equal 'Wisconsin'
var cityName = this.city;
// 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
jHash.val({
name: 'Steve',
location: 'Montana'
});
// clear the hash
jHash.clear();
// clear just the hash root value
jHash.clearRoot();
// clear just the hash querystring
jHash.clearQuery();
```
## Articles / News
2012-05-01 - [jHash v2.0 Released: Now with Routing Support!](http://pietschsoft.com/post/2012/05/01/jHash-v20-Released-Now-with-Routing-Support!.aspx)
2010-11-26 - [jHash: Easily Manage Browser History / window.location.hash](http://pietschsoft.com/post/2010/11/26/jHash-Easily-Manage-Browser-History-windowlocationhash.aspx)