I have a spring-boot/thymeleaf application that submits a query to a Webclient service. While the webclient performing the get request, I display a spinner on the form page. After the results are retrieved the application redirects to the template in the @PostMapping method, displays the results, and since it's a new page no more spinner. Works as desired.
But, if the user stops the page load while the webclient is performing the get request the spinner remains since no EventListener is registered with the stop load to hide the spinner. So I was wondering:
What DOM/Window event is trigger when the stop load page is pressed? I tried document.onabort, document.oncancel, window.onabort, window.oncancel, window.onunload, etc. and nothing. I added document and window click event listeners below (as well as abort, cancel) and confirmed that nothing gets logged when stop load is pressed.
And for future debugging/testing, is there a console.log debugging code I use to "follow" the navigation click similar to this:
document.addEventListener("click", (event) => {
console.log(event)
})
window.addEventListener("click", (event) => {
console.log(event)
})
Am I out of luck trying to do this with javascript? Is there a pure Spring/Thymeleaf alternative for this logic?