-2

Whenever I press the back button on https://automotive-electronics.nl the page loader does not hide. I have found out that this is caused because the javascript seems to be cached (if there is such a thing). I have added a console log at the top of the javascript file, which logs "test" to the JS console. Whenever I load the page normally it logs "test". When clicking a link it also logs test and when going back it still logs test, so everything seems fine. However, something weird happens when going back:

To me it seemed like the logging in the console was instantly, hence I felt like something was wrong so I tried the following:

  1. Go to the home page -> test is logged, so this is fine
  2. Clear the JS console -> test is not logged anymore, which makes sense as I have just cleared the console
  3. Go to any page other than the home page -> test is logged, which is fine
  4. Press either the browser of mouse back button which will take you back to the homepage -> test is NOT logged, which is not fine

Since test is logged when not clearing the console and test is not logged when clearing the console, this leads me to believe that the JS is cached somehow, however, I do not know how to fix this issue. I have also found that this does not happen 100% of the time, but it does happen way too often. I am using Google Chrome to test things. Is anyone able to help me? Thanks in advance :)

UPDATE: After some testing it seems to only happen when both the initial page, and the second page have been visited recently (I'm assuming they should both be in your cache in order to work).

1 Answers1

1

If anyone else is running into this problem; I have fixed it by adding window.onunload = function(){}; to the first line of the file, as suggested in After travelling back in Firefox history, JavaScript won't run. Thanks to mplungjan for taking the time to look into the issue with me!