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

Overview

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.

You might also like...

In 2012 the King of Spain, Juan Carlos I, transferred 65 million euros to a friend from a secret account in Switzerland. What lies actually behind this rare donation? This repository contains the full source code of the website ladonacion.es.

La Donación full source code and documentation This documentation draft is a work in progress. I expect to have it completed by September 24, 2022. ⭐

Dec 24, 2022

Use better-sqlite3 to give obsidian the ability to manipulate sqlite3 databases

OBSIDIAN-SQLITE3 Use better-sqlite3 to give obisidian the ability to manipulate sqlite3 databases. Intention Currently the linkage between obsidian an

Nov 28, 2022

In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaScript index file that imported all the modules and assets

In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaScript index file that imported all the modules and assets

To Do List In this project, I built a simple HTML list of To-Do tasks. This simple web page was built using Webpack, creating everything from a JavaSc

Mar 31, 2022

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing 🎯 About

Jan 1, 2023

A dockerized uptime monitoring RESTful API server that allows authenticated users to monitor URLs

A dockerized uptime monitoring RESTful API server that allows authenticated users to monitor URLs, and get detailed uptime reports about their availability, average response time, and total uptime/downtime.

Oct 7, 2022

Transform URLs in strings to actual links.

Transform URLs in strings to actual links.

Transform URLs in strings to actual links. It will find valid links in the given string and create a tags for it. Internally, it uses this Regex to

Nov 4, 2022

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines.

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines.

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines. A timeline is a collection of links that share a common topic or a journey of building and learning something new. Users can create timelines, share them publicly, and explore resources.

Jun 13, 2022

Generate colorful and temporarily identifiable SVGs with unique urls.

Generate colorful and temporarily identifiable SVGs with unique urls.

reptiles.dev Generate colorful and temporarily identifiable SVGs with unique urls.

Dec 6, 2022

Uptime monitoring RESTful API server that allows authenticated users to monitor URLs, and get detailed uptime reports about their availability, average response time, and total uptime/downtime.

Uptime Monitoring API Uptime monitoring RESTful API server that allows authenticated users to monitor URLs, and get detailed uptime reports about thei

Jun 14, 2022
Comments
  • How to support multiple tags?

    How to support multiple tags?

    How can I get this to support

    hash.add({ state: [1, 2] });

    such that the url looks like:

    www.devnull.com#state=1&state=2

    or is that not supported?

    opened by wheaties 1
  • Account for hashbangs

    Account for hashbangs

    Allows hash.js to parse hashbang URLs natively.

    https://developers.google.com/webmasters/ajax-crawling/docs/specification

    I didn't include tests because I'm not too familiar with JS unit tests.

    I didn't include a minified version because I don't know what minification library is used, but I can update the pull request with a minified version if needed.

    opened by mintindeed 0
Owner
Jonny Strömberg
Co-founder Confetti, Nordic.js and Nordic.design. Co-organizer Sthlm.js
Jonny Strömberg
A simple to-do app for managing daily tasks built with Webpack, JavaScript, HTML, and CSS with the functionality to manipulate multiple completed tasks and store them to local storage.

TODO LIST APP In this project, I have built a simple HTML list of To Do tasks. The list is styled according to the listed specifications . This simple

Selma Belhadj 8 Jun 7, 2022
Eth-explorers-extension - Chrome extension to open Ethereum addresses & transaction hash from any page on popular explorers + dashboards

eth-explorers-extension(s) This repository contains two folders with two extensions that work for address and transactions respectively. 1. eth-addres

Apoorv Lathey 71 Jan 6, 2023
BRIDGE is a collaborative project for fx(hash), conceived by Camille Roux.

BRIDGE collaborative project for fxhash BRIDGE is an experimental project for fxhash. Any artist can contribute. The main rule: draw the tiles at the

Camille Roux 11 Jul 22, 2022
Project template repo for generative art projects on the fx(hash) platform

fx(hash) x thi.ng project template About This template repo provides a compact, ready-to-go scaffolding for generative art projects aimed at the fx(ha

thi.ng 38 Dec 21, 2022
A Drag-and-Drop library for all JavaScript frameworks implementing an enhanced transformation mechanism to manipulate DOM elements

JavaScript Project to Manipulate DOM Elements DFlex A Drag-and-Drop library for all JavaScript frameworks implementing an enhanced transformation mech

DFlex 1.5k Jan 8, 2023
Ready to manipulate partitions file? Create a custom partition, apply custom security system, hide the partition and share your hidden data on the www

Paranoia ?? Ready to manipulate partitions file? Create a custom partition, apply custom security system, hide the partition and share your hidden dat

Alice Snow 3 Dec 29, 2022
Manipulate the AST to transform your code.

unplugin-ast Manipulate the AST to transform your code. Installation npm i unplugin-ast Vite // vite.config.ts import AST from 'unplugin-ast/vite' ex

三咲智子 32 Dec 3, 2022
Manipulate Clipboard in Node.js via native API.

@napi-rs/clipboard Manipulate Clipboard in Node.js via native API. It's a Node.js binding for 1Password/aboard API Text import { Clipboard } from '@na

LongYinan 64 Nov 7, 2022
A package to manipulate string.

A package to manipulate string. Instalation use this command to installation npm install best-string imports import BestString from 'best-string' //o

sajjad isvand 4 Nov 17, 2022
Customizable masonry Flatlist. it just behave like Flatlist but using ScrollView behind the scene

Would you like to support me? react-native-masonry-grid Customizable masonry Flatlist. it just behave like Flatlist but using ScrollView behind the sc

Numan 5 Sep 7, 2022