Index: openacs-4/packages/acs-templating/tcl/head-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/head-procs.tcl,v diff -u -r1.44 -r1.45 --- openacs-4/packages/acs-templating/tcl/head-procs.tcl 19 Sep 2018 00:38:52 -0000 1.44 +++ openacs-4/packages/acs-templating/tcl/head-procs.tcl 24 Oct 2018 17:01:58 -0000 1.45 @@ -991,7 +991,28 @@ {*}$cmd } +ad_proc template::add_refresh_on_history_handler {} { + Register an event handler which will trigger a complete page + refresh when we land on this page by accessing the browser's + history (back and forward buttons). + This is useful e.g. for those pages where some push interaction is + happening and retrieving the page from the browser history would + display it in an inconsistent state. +} { + # courtesy of: vasleo@gmail.com from Stack Overflow + template::add_body_script -script { + window.addEventListener( "pageshow", function ( event ) { + var historyTraversal = event.persisted || + ( typeof window.performance != "undefined" && + window.performance.navigation.type === 2 ); + if ( historyTraversal ) { + window.location.reload(); + } + }); + } +} + ad_proc template::add_event_listener { {-event click} {-CSSclass "acs-listen"}