2012 október - 2 megfelelő bejegyzés

Mutass mindent

Jelöld be, hogy főbb mely kategóriákat akarod olvasni, vagy ha csak egyet: kattints a nevére.


HTML5 history management

©   Haszprus   |   fejlesztés

Today I've learnt a small but very exciting feature, html 5 history management:

window.history.pushState(data, "Title", "/new-url");

Paired with:

window.onpopstate = function(event) { 

This way you can set the window.location to your custom new url without reloading the page (or even without any communication with the server), but creating an entry in the browser's history (so the user can go back and forward between the saved states), and saving any custom state data as the first attribute of pushState().

With onpopstate you can catch the browser's navigation events and load the previously saved state to your page (eg. fill forms, request ajax page elements etc).

HTML5 has it's very funky features.

9 queries