GithubHelp home page GithubHelp logo

rdworth / simple-history Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jzaefferer/simple-history

2.0 2.0 0.0 65 KB

A simple JavaScript HTML5 history library

Home Page: http://jzaefferer.github.com/simple-history/

JavaScript 100.00%

simple-history's Introduction

Simple History

This is a JavaScript library to lightly wrap the HTML5 history API, promoting the API in its most useful form, without a hashchange fallback or trying to fix irrelevant bugs.

If you need an implementation with hashchange fallback, give History.js a try.

Usage

Before you intialize any relevant event handlers, check if HTML5 history is supported:

if (SimpleHistory.supported) {
	// event handlers
}

When support is available, use SimpleHistory.start to notified whenever state changes:

SimpleHistory.start(function(fragment) {
  // pass to router
});

That callback is called once immediately, then whenever a state change occurs (push or pop).

To trigger a state change manually, use the pushState and replaceState methods:

SimpleHistory.pushState(fragment);
SimpleHistory.replaceState(fragment);

As with the underlying API, pushState adds a history entry, replaceState replaces the current history entry. Use replaceState whenever you implement a redirect.

Roadmap

This library is intended to be kept as simple as it is now. It won't ever support a hashchange fallback, nor updating document.title. If you find an issue, please file a ticket. Of course, patches (via Pull Requests) are welcome.

License

Copyright 2011, Jörn Zaefferer

Dual licensed under the MIT or GPL Version 2 licenses.

simple-history's People

Contributors

jzaefferer avatar

Stargazers

Kushal Shingote avatar Richard D. Worth avatar

Watchers

Richard D. Worth avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.