Welcome to History.js
See the History.md file for a detailed list of features, changes, solved issues and bugs
Please create an issue if something doesn't work or if there is a browser specific bug. I'll try to fix it as soon as possible. Please send me your Pull requests if you have a nice solution! I'm also going to review old issues in balupton's repository and try to solve them too.
data, title, pushState and replaceState) with the option to remove HTML4 support if it is not right for your applicationTo ajaxify your entire website with the HTML5 History API, History.js and jQuery the Ajaxify Script is all you need. It's that easy.
If you are using Rails, then the easiest way for you to try History.js would be to use Wiselinks gem. Wiselinks integrates into Rails application and allows you to start using History.js with three lines of code.
(function(window,undefined){
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
});
// Change our States
History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1"
History.pushState({state:2}, "State 2", "?state=2"); // logs {state:2}, "State 2", "?state=2"
History.replaceState({state:3}, "State 3", "?state=3"); // logs {state:3}, "State 3", "?state=3"
History.pushState(null, null, "?state=4"); // logs {}, '', "?state=4"
History.back(); // logs {state:3}, "State 3", "?state=3"
History.back(); // logs {state:1}, "State 1", "?state=1"
History.back(); // logs {}, "Home Page", "?"
History.go(2); // logs {state:3}, "State 3", "?state=3"
})(window);
Note: These urls also work in HTML4 browsers and Search Engines. So no need for the hashbang (
#!) fragment-identifier that google "recommends".
Note 1: These urls also work in HTML5 browsers - we use
replaceStateto transform these HTML4 states into their HTML5 equivalents so the user won't even notice :-)Note 2: These urls will be automatically url-encoded in IE6 to prevent certain browser-specific bugs.
Note 3: Support for HTML4 browsers (this hash fallback) is optional - why supporting HTML4 browsers could be either good or bad based on my app's use cases
title and/or data in our state. Adding a SUID allows us to associate particular states with data and titles while keeping the urls as simple as possible (don't worry it's all tested, working and a lot smarter than I'm making it out to be).title or data then we don't even include a SUID (as there is no need for it) - as seen by State 4 above :-)http://www.mysite.com/#http://www.mysite.com/projects/History.js to become http://www.mysite.com/#/projects/History.js automatically. (again tested, working, and smarter).Download History.js and upload it to your webserver. Download links: tar.gz or zip
Include History.js
For Dojo v1.8+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/dojo.history.js"></script>
For ExtJs v1.8+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/extjs.history.js"></script>
For jQuery v1.3+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
For Mootools v1.3+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/mootools.history.js"></script>
For Right.js v2.2+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/right.history.js"></script>
For Zepto v0.5+
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/zepto.history.js"></script>
For everything else
html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/native.history.js"></script>
Note: If you want to only support HTML5 Browsers and not HTML4 Browsers (so no hash fallback support) then just change the
/html4+html5/part in the urls to just/html5/. See Why supporting HTML4 browsers could be either good or bad based on my app's use cases
History.js is maintained by people like you. If you find a bug, report it to the GitHub Issue Tracker. If you've fixed a bug submit a Pull Request and add your fork to the Network Wiki Page.
If you would like paid support and trainings, or have job offers, then refer to the Network Wiki Page. If you are qualified with History.js, then be sure to add your details to that page too.
If your company uses History.js on your projects, and would like to see it grow and prosper (better documentation, bugfixes, upgrades, maintenance, etc.) and would love to become a corporate sponsor then do email sponsor@bevry.me
If you would like free support for History.js, then post your question on Stackoverflow and be sure to use the history.js tag when asking your question.
If you've created a website that uses History.js, or know of one, be sure to add it to the Showcase Wiki Page.
If you'd love to +1 or like this project, then be sure to tweet about it and click the "watch" button up the top of its Project Page.
For anything else, refer to the History.js GitHub Wiki Site.
Thanks! every bit of help really does make a difference!
History.pushState(data,title,url) Pushes a new state to the browser; data can be null or an object, title can be null or a string, url must be a string
- History.replaceState(data,title,url)
Replaces the existing state with a new state to the browser; data can be null or an object, title can be null or a string, url must be a string
- History.getState()
Gets the current state of the browser, returns an object with data, title and url
- History.getStateByIndex
Gets a state by the index
- History.getCurrentIndex
Gets the current index
- History.getHash()
Gets the current hash of the browser
History.Adapter.bind(element,event,callback) A framework independent event binder, you may either use this or your framework's native event binder.
- History.Adapter.trigger(element,event)
A framework independent event trigger, you may either use this or your framework's native event trigger.
- History.Adapter.onDomLoad(callback)
A framework independent onDomLoad binder, you may either use this or your framework's native onDomLoad binder.
History.back() Go back once through the history (same as hitting the browser's back button)
- History.forward()
Go forward once through the history (same as hitting the browser's forward button)
- History.go(X)
If X is negative go back through history X times, if X is positive go forwards through history X times
History.log(...) Logs messages to the console, the log element, and fallbacks to alert if neither of those two exist
- History.debug(...)
Same as History.log but only runs if History.debug.enable === true
History.options.hashChangeInterval How long should the interval be before hashchange checks
- History.options.safariPollInterval
How long should the interval be before safari poll checks
- History.options.doubleCheckInterval
How long should the interval be before we perform a double check
- History.options.disableSuid
Force History not to append suid
- History.options.storeInterval
How long should we wait between store calls
- History.options.busyDelay
How long should we wait between busy events
- History.options.debug
If true will enable debug messages to be logged
- History.options.initialTitle
What is the title of the initial state
- History.options.html4Mode
If true, will force HTMl4 mode (hashtags)
- History.options.delayInit
Want to override default options and call init manually.
window.onstatechange Fired when the state of the page changes (does not include hash changes)
- window.onanchorchange
Fired when the anchor of the page changes (does not include state hashes)
$ claude mcp add history.js \
-- python -m otcore.mcp_server <graph>