This method can have optional parameters true and false. The true keyword force to reload the page from the server, while the false keyword reloads the page from the cache.
The false is the default parameter of this method, so if we omitted the parameter's value, the reload() method reloads the page from the cache. It means that the object.reload() is same as the object.reload(false).
Let's see an example of using the location.reload() method.
Here, the function fun() contains the location.reload() method. We are calling the function fun() using the onclick attribute of the button element. So, we have to click the given HTML 'Reload' button to see the effect. After clicking the button, the page will reload.Test it Now
In the above example, instead of calling the fun() function, we can also attach the location.reload() method to the button markup. It can be done as given below:
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week