8249133: Javadoc: Browser back navigation does not jump to previous position anymore

Reviewed-by: jjg
This commit is contained in:
Hannes Wallnöfer 2020-07-17 12:54:12 +02:00
parent 955aee3bfa
commit e13cb76baa

@ -101,3 +101,26 @@ function indexFilesLoaded() {
&& memberSearchIndex
&& tagSearchIndex;
}
// Workaround for scroll position not being included in browser history (8249133)
document.addEventListener("DOMContentLoaded", function() {
var contentDiv = document.querySelector("div.flex-content");
window.onpopstate = function(e) {
if (e.state !== null) {
contentDiv.scrollTop = e.state;
}
}
window.onhashchange = function(e) {
history.replaceState(contentDiv.scrollTop, document.title);
}
contentDiv.onscroll = function(e) {
var timeoutID;
if (!timeoutID) {
timeoutID = setTimeout(function() {
history.replaceState(contentDiv.scrollTop, document.title);
timeoutID = null;
}, 100);
}
}
history.replaceState(contentDiv.scrollTop, document.title);
});