https://github.com/nomocas/min-history
HTML5 History API polyfill for IE8+, ... Simple, minimal, workable, testable.
https://github.com/nomocas/min-history
Last synced: 6 months ago
JSON representation
HTML5 History API polyfill for IE8+, ... Simple, minimal, workable, testable.
- Host: GitHub
- URL: https://github.com/nomocas/min-history
- Owner: nomocas
- License: mit
- Created: 2014-09-18T13:04:40.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-24T16:32:19.000Z (about 10 years ago)
- Last Synced: 2024-04-25T10:01:03.576Z (about 1 year ago)
- Language: JavaScript
- Size: 258 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# min-history : html5 history shim for IE8+, FF3+, Chrome, Safari, ...
```html
My Link
Other Link
third Link
third Link
third Link doe
bar
bar zoo
bar bloupi zoo
(function() {if (history.emulated)
console.log('Emulated Html5 History API');
else
console.log('Native Html5 History API');history.init({
hashChangeAlone: true,
setStateEvent:true,
basePath: "/example",
hid:true
});var count = 0;
var links = document.querySelectorAll('a.ajax');
for (var i = 0; i < links.length; i++)
{
links[i].onclick = function(e) {
console.log("CLICK");
if(e && typeof e.preventDefault !== 'undefined')
e.preventDefault();
history.pushState({
hello: "world " + (++count)
},
this.title || ("hello world : " + count),
this.href);
return false;
};
}
// popstate event from back/forward in browser
window.addEventListener('popstate', function(e) {
console.log("* POP STATE : " + history.location.relative, " - ", JSON.stringify(history.state));
});// hashchange event from back/forward in browser
window.addEventListener('hashchange', function(e) {
console.log("* HASH CHANGE " + history.location.hash, " - ", JSON.stringify(history.state));
});// setstate event when pushstate or replace state
window.addEventListener('setstate', function(e) {
console.log("* SET STATE " + history.location.relative, " - ", JSON.stringify(history.state));
});})();
```