Last Updated : Jul 1, 2023
You can use location.reload() to accomplish the same thing as pressing the browser's reload button.
The browser's cache is used by default when this method is used to reload the page.
Loading a page from the session history with history.go():
By changing the delta parameter, forward or backward motion can be achieved.
By setting delta to a positive value, the page will advance in history. In the case of a negative delta value, the page would revert to the previous one.
Using "-1" as the delta value will take you one page back in history. By specifying the onclick event, a page in history can be returned one page.
A URL (page) from the history list can be accessed by calling history.back().
The history.back() method only works if a previous page exists.
The idea is that, when clicking on an anchor within a wrapper element (#wrapper), the content of the linked page is shown.
In place of a full-page refresh/transition, a custom loader element (#loader) is shown for a short period while the linked page's content is being loaded.
The title and body of the page is replaced with those of the loaded linked page.
This way is sub-optimal. For example, one major drawback is that the back functionality does not work; the previous page does not load when navigating via the browser's back button.
You can use either method for adding or replacing URLs in the browser's history. A different website cannot be navigated to through the History API, since it only supports same-origin URLs.
It is assumed that False will be the default value in this case. The method object.reload() does the same thing as object.reload(false), as it reloads the page using the browser's cached data.
By calling the method when the user performs an event rather than automatically refreshing the page when the user clicks a button, the web page will be refreshed when the user clicks a button.
The page will be refreshed after clicking the Reload Page button after the location.reload() method is called.
- In our first step, we write <HTML>, which tells the browser what HTML version we're using. Documents in HTML begin with tags.
- Using the <head> tag, we will explain the project's heading. <title> are open and </title>.
- An external style sheet that is referenced with a full URL or with a path relative to the current web page is referred to as a step-by-step style sheet.
- Then we use <b> tag and <p> tag for bold and paragraph.
- Then we use onclick directive for detecting click events and an ng-class directive for adding up and down arrows. ng-click and ng-class directives contain a function that takes the key name as a parameter.
- Then we use hyperlink for redirecting page without refresh.
- After that </body></html> and code should be executed after closing all tags.
The window. the location has a href property. This returns the URL of the current website.
In this example, this property is used for reloading and refreshing the current page.
This property can also be used to target another page and refresh it.