location.reload

In this chapter you will learn:

  1. How to use reload method from Location
  2. How to force a reload

reload method

location.reload() reloads the current page.

<!DOCTYPE HTML> <!--  j  a va 2s. c  o  m-->
<html> 
    <body> 
        <script> 
               location.reload(); //reload - possibly from cache 
        </script> 
    </body> 
</html>

Click to view the demo

Force a reload

To force a reload from the server, pass in true as an argument like this:

<!DOCTYPE HTML> <!-- j  a  v a 2s.com-->
<html> 
    <body> 
        <script> 
              location.reload(true); //reload - go back to the server 
        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to replace url for location object
Home » Javascript Tutorial » Location
Location
assign method
Location.hash
Location.hostname
Location.href
location.pathname
location.port
location.reload
location.replace()
Location.search