Haszprus

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) { 
    console.log(event.state); 
};

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.

RSS: hozzászólások ehhez a bejegyzéshez Rajtad a világ szeme

Szólj hozzá Te is!
Hozzászólásod:


Nem vagy bejelentkezve, de...

A)
hozzászólhatsz regisztrálatlanul...

B)
ha regisztrálva vagy, bejelentkezhetsz...