{% extends "base.html" %} {% block script %} const STATE_BACK = "back"; const STATE_FORWARD = "forward"; function switch_state(new_state) { history.replaceState( new_state, document.title, location.pathname+location.hash); } function go_back() { switch_state(STATE_FORWARD); history.back(); } function go_forward() { switch_state(STATE_BACK); history.forward(); } // there are three states // default: register focus listener, // on focus: go back and switch to the state forward // back: user came from a later history entry // -> switch to the state forward, // forward him to the previous history entry // forward: user came from a previous history entry // -> switch to the state back, // forward him to the next history entry switch (history.state) { case STATE_BACK: go_back(); break; case STATE_FORWARD: go_forward(); break; default: if (!document.hidden) { go_back(); break; } document.addEventListener("visibilitychange", go_back); break; } {% endblock %} {% block content %}

If you see this site something went wrong or you reached the end of the history or you disabled javascript.

{% endblock %}