ENGLISH
This Javascript library provides an emulation of HTML5 History API for older browsers.
The library operates according to W3C specification, adding no new or incompatible methods. The library can be used exactly as described, for example, in Dive Into HTML5 book (http://diveintohtml5.info/history.html) or in the History API Specification (http://www.w3.org/TR/html5/browsers.html#the-history-interface).
You may install this plugin with this command:
npm install html5-history-api
Browser Support:
history.js
- IE8+ and other browsers
history.ielte7.js
- IE6+ and other browsers
For library developers:
To enable support for HTML5-History-API polyfill in your library, you need to add one line of code:
var location = windowhistorylocation || windowlocation;
code of library looks like this:
{ // To enable support for HTML5-History-API polyfill in your library var location = windowhistorylocation || windowlocation; // you library code here // .... // .... // ....};
AMD Support:
Example of using the library in the pure JS context:
My Link Other Link
Example of using the library along with JQuery:
My Link Other Link
Advanced library configuration:
history.js?basepath=/pathtosite/ - the base path to the site; defaults to the root "/".
history.js?redirect=true - enable link translation.
history.js?type=/ - substitute the string after the anchor; by default "/".
You can also combine options:
history.js?type=/&redirect=true&basepath=/pathtosite/ - the order of options does not matter.
Or execute special method in JavaScript:
history;
Demo Site: http://history.spb-piksel.ru/ or http://devote.github.io/demos/history/
Follow me on Twitter: https://twitter.com/DimaPakhtinov
РУССКИЙ
Библиотека эмулирует HTML5 History API в старых браузерах.
Библиотека, которая не добавляет ненужные методы, заставляя их изучать, а оперирует по спецификации w3c, по интерфейсу History.
Для примера могу привести короткий код как с ней работать.
По принципу мы работаем с HTML5 History API так как описано, например, тут http://htmlbook.ru/html5/history или по спецификации http://www.w3.org/TR/html5/history.html#the-history-interface
Вы можете установить плагин с помощью команды:
npm install html5-history-api
Поддержка браузеров:
history.js
- IE8+ и другие браузеры
history.ielte7.js
- IE6+ и другие браузеры
Для разработчиков библиотек:
Для включения поддержки плагина HTML5-History-API polyfill в своих библиотеках, добавьте строку кода:
var location = windowhistorylocation || windowlocation;
код будет выглядеть примерно так:
{ // Включает поддержку плагина HTML5-History-API polyfill var location = windowhistorylocation || windowlocation; // код вашей библиотеки // .... // .... // ....};
Поддержка AMD:
Коротенький пример на чистом JS:
My Link Other Link
А теперь показываю пример в связке с jQuery:
My Link Other Link
Вы можете использовать дополнительные параметры конфигурации библиотеки:
history.js?basepath=/pathtosite/ - базовый путь к сайту, по умолчанию имеет значение корня "/".
history.js?redirect=true - включить преобразование ссылок.
history.js?type=/ - подставлять подстроку после якоря, по умолчанию имеет символ "/".
Также вы можете комбинировать опции:
history.js?type=/&redirect=true&basepath=/pathtosite/ - порядок опций не имеет значение.
Или выполнить специальный метод в JavaScript:
history;
Демо-сайт: http://history.spb-piksel.ru/ или http://devote.github.io/demos/history/
Я в Twitter: https://twitter.com/DimaPakhtinov