Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (42 sloc) 1.712 kb
3d4120b8 »
2010-07-22 Initial Version. Supports IE8, FF3.6, Chrome, and Safari
1 # history.js
2
3 history.js provides an implementation of the [HTML5 history API](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-history-interface): `history.pushState` and `history.replaceState` functions, as well as the `window.onpopstate` event.
4
5 Browsers that already support his event (Chrome & Safari, Firefox 4+) use native implementations, which are able to change the page URL without refreshing the page. Older browsers use `location.hash` in order to mimic the official behavior.
6
550c3721 »
2010-08-10 Redirect on load of a generated hash is detected
7 1214 bytes minified / 588 bytes gzipped
8
3d4120b8 »
2010-07-22 Initial Version. Supports IE8, FF3.6, Chrome, and Safari
9 ## Limitations
10
11 * Does not support multiple handlers for the `onpopstate` event
12
13 ## Installation
14
15 Include the script file in your HTML file:
16
17 <!-- Include JSON if you want to support older browsers -->
18 <script type="text/javascript" src="json2.js"></script>
19 <script type="text/javascript" src="history-min.js"></script>
20
21 ## Usage
22
23 Same as the official HTML5 API:
24
25 // Switch to the item
26 window.history.pushState({ id: 35 }, 'Viewing item #35', '/item/35'});
27
28 window.onpopstate = function (e) {
29 var id = e.state.id;
30 load_item(id);
31 };
32
33 Any use allowed in the standard but not supported by this API is considered a bug.
34
35 ## Supported & Tested Browsers
36
37 * Chrome 5+ & Safari 5+ (Native)
38 * Firefox 4+ (Native)
39 * Firefox 3.5+
40 * Chrome 4+
41 * Safari 4+
42 * IE8+
43
44 ## Unsupported / Need to test
45
46 * Opera ?
47 * IE6-7
48 * Safari 3+ (No persitence)
49 * Chrome 3+ (No persitence)
50 * Firefox 2+ (No persitence)
51
52 ## TODO
53
54 * Support IE6&7
55 * Use `iframe` for history
56 * Use `userData` behavior for persistence
57 * Support FF2+
58 * Use `globalStorage` for persistence
59 * Chrome < 4
60 * Use Gears?
61 * Fallback for browsers that are unsupported
Something went wrong with that request. Please try again.