• Stars
    star
    155
  • Rank 232,843 (Top 5 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls.

Hash.js - URL Hash Manipulation

Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls. Tested in latest Chrome, Safari, Firefox and IE7,8,9.

See example page at jonnystromberg.com/hash-js or see it in action at PNGTextures.com.

Btw, follow me (@javve) at Twitter and checkout my other project List.js

Notice: The main focus of Hash.js is simplicity. This is no tool for your super-ajax-native-feeling-app-with-google-bot-support. If that's your usage situation, use the awesome History.js.

Usage

Just include hash.min.js or hash.js at your site and then a hash object will become available.

<script src="hash.min.js"></script>

<script>
    hash.add({foo: "bar" });                // Url becomes http://url.com#foo=bar
</scrtip>

Methods

  • hash.add(params)
    Add parameter to hash

      hash.add({ foo: "bar" });               // http://url.com#foo=bar
      hash.add({ car: "dar", sar: "par" });   // http://url.com#foo=bar&car=dar&sar=par
    
  • hash.get(param) or hash.get()
    Returns value of paramter in hash. If param is undefined then all values are returned.

      var fooValue = hash.get('foo');         // fooValue == "bar"
      var allValues = hash.get();             // allValues == { foo: "bar", car: "dar", sar: "par"}
    
  • hash.remove(param)
    Removes the value with name param.

      hash.remove('foo');                     // http://url.com#car=dar&sar=par
    
  • hash.clear()
    Clears entire hash.

      hash.clear();                           // http://url.com#
    

License

DON'T BE A DICK PUBLIC LICENSE

Version 1, December 2009

Copyright (C) 2011
Jonny Strömberg @javve

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

DON'T BE A DICK PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. Do whatever you like with the original work, just don't be a dick.
    Being a dick includes - but is not limited to - the following instances:

    1a. Outright copyright infringement - Don't just copy this and change the name.

    1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.

    1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.

  2. If you become rich through modifications, related works/services, or supporting the original work, share the love. Only a dick would make loads off this work and not buy the original works creator(s) a pint.

  3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.

More Repositories

1

list.js

The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.
JavaScript
11,152
star
2

list.fuzzysearch.js

A fuzzy search plugin for List.js
JavaScript
44
star
3

tictail-theme-builder

This project basically enables you to build your theme locally on your own computer with your favorite editor, as you normally make websites.
Ruby
42
star
4

natural-sort

Natural sort algorithm with unicode support written by Jim Palmer
HTML
39
star
5

pngtextures.com

PNG Textures - The super smooth way to create and share hip textures.
JavaScript
32
star
6

list.pagination.js

A pagination plugin for List.js
JavaScript
24
star
7

box2d-javascript

Here is a demo that I made for a presentation @sthlmjs, more info soon!
JavaScript
13
star
8

framerjs-workshop

This workshop is intended for the Mobile Design module at Hyper Island.
JavaScript
12
star
9

us-js

JavaScript
10
star
10

mongoose-js-example

It is a example of how I use Mongoose.js in my personal projects.
JavaScript
8
star
11

flag.js

JavaScript
4
star
12

list-website

The List.js website
CSS
4
star
13

get-attribute

A cross-browser implementation of getAttribute
JavaScript
3
star
14

my-first-html-page-ever-1998-04-22

This repo contains the first HTML page I wrote when I was 12 years old. Pure awesomeness!
HTML
3
star
15

shrug-logo

The logotype for Stockholm Ruby User Group (SHRUG)
2
star
16

finalfantasy.se

CSS
2
star
17

javve.github.io

JavaScript
2
star
18

get-by-class

A cross-browser implementation of getElementsByClass.
JavaScript
2
star
19

rack-project-template

A quick and clean rack project template for Heroku
JavaScript
2
star
20

events

Element event binding component with support for single elements as well as NodeLists and Arrays.
JavaScript
2
star
21

to-string

A minimal Javascript component for converting anything to a string
JavaScript
1
star
22

closingweek.com

HTML
1
star
23

bootstrap-workshop

Assignments for my Bootstrap workshop at Hyper Island 2013-09-25
CSS
1
star
24

jjexp

JavaScript
1
star