2.0.0 • Published 7 years ago

history-state v2.0.0

Weekly downloads
19
License
MIT
Repository
-
Last release
7 years ago

history-state

history-state allows you to monitor and make changes to a page’s history state.

Browser support

Install

$ npm install history-state

API

By default, the mechanisms used are history.pushState and window.onpopstate, with older browsers falling back to location.hash and window.onhashchange. This behaviour can be overridden by passing the constructor an options object, detailed below.

var state = require('history-state')({
  // Use only location.hash/onhashchange…
  hash: true,
  // …or use only history.pushState/onpopstate.
  pushState: true
})

state.change('/some-path')

state.on('change', function() {
  console.log(location.pathname)
  > '/some-path'
})

// Toggle the window listeners.
state.stop()
state.start()

License

MIT

2.0.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago