FIX: Browser back button doesn’t reload page in JavaScript

Milan Stanojevic
by Milan Stanojevic
Deputy Editor
0 Comments
Download PDF
Affiliate Disclosure

  • People love browsing the internet. Did you know the volume of search queries grows by 10% every year?
  • Your browser's back button allows your to reload previously visited pages which is a very useful option especially when web pages become unresponsive.
  • If the back button of your browser fails to reload pages, we found the solution to your problems and listed it in this guide.
  • Speaking of browser issues, we recommend bookmarking our troubleshooting hub just in case you need to fix other browser glitches later on.
back button doesn't work

Quite a few users, and especially programmers encountered an issue when working in JavaScript. They want to be able to reload the web-page the user is observing by using the back button inside the browser.

If the code fails to update the cached data from the initial page, the back button will show the cached data, but without the latest data updates applied.

This can cause a lot of confusion especially if the web-page you’re working on is a complex project with a lot of complicated commands.

Even though each browser manages cache differently, the fix we’re discussing in this article will be using JavaScript, so it applies to any browser. Read on to find out how to do it.

What to do if the browser backup button doesn’t load updated cache data

Because Maintenance applications have two pages – the ‘List’, and ‘Maintain’ view, we will tackle this issue focusing only on the ‘List’ page.

In order to achieve reloading cached data when users press the back button of a web-page inside a browser, you will need to copy-paste this command directly before the </head> tag , inside the source view of the ‘List’ layer: 

<script type="text/javascript">
       jQuery(document).ready(function()
        {
                var d = new Date();
                d = d.getTime();
                if (jQuery('#reloadValue').val().length == 0)
                {
                        jQuery('#reloadValue').val(d);
                        jQuery('body').show();
                }
                else
                {
                        jQuery('#reloadValue').val('');
                        location.reload();
                }
        });
   </script>

After this code is added to your ‘List’ layer, you will also need to add a line of code after the <– End data Table -> text:

<input id =''reloadValue'' type =''hidden'' name =''reloadValue'' value=''/>

After this process is done, the user that is browsing your website will be able to reload the previous page with the updated live cache data, by simply clicking the back button.


Wondering why you should still download Java code on Windows 10? Here’s the answer.


Please feel free to let us know if this short guide helped you solve your issue in JavaScript.

Speaking of browsers, if you got tired of your current browser and you’re looking to switch to a new one, why not try Opera. It’s fast, secure, privacy compliant, and fully customizable.

More so, it is frequently updated, and therefore improved upon, so any bug you may happen to find will never stay there for long anyway.

Opera

Opera

Choose this browser and never have to worry about coding problems like JavaScript-related issues. Available for download for free!

FAQ: Learn more about browsers

  • What is the browser back button?

The back button of a browser allows users to return to a web page they previously visited. This option is extremely useful especially if you don’t recall on what page you found one particular piece of information.

  • Can I disable the browser back button?

The back button of a browser cannot be disabled by users. Only the companies that own the respective browsers can operate such changes in the browser’s code.

  • Why can’t I go back from some websites?

Some websites embed special code in their page scripts that disable the function of your browser’s back button preventing users from returning to pages they previously visited.

Editor’s Note: This post was originally published in June 2019 and has since been updated for freshness and accuracy.