/Hashuery

A JavaScript library to parse query in URL's Hash.

Primary LanguageJavaScript

Hashuery

A JavaScript library to parse query in URL's Hash.

Example:

When URL looks like:

http://example.com/#this=hash&data=anything

Would be returned as a JavaScript object:

{
    "this": "hash",
    "data": "anything"
}

Usage

Initialize:

var hash = new hashuery();

Getting the current value:

var current = hash.get();

Setting a new value:

hash.set({
    "foo": "bar"
});

Append data instaed of setting:

hash.append({
    "baz": "bar"
});

Clear URL

hash.clear();

Events:

It has two events:

.onChange(function(newHash){}) // pass the function to be called when hash changes

and

.onClear(function(){}) // pass the function to be called when hash is cleared