Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

onpopstate can i use?

1 Answer(s) Available
Answer # 1 #

The methods pushState() and replaceState() both serve to modify the current session's history entries in some way or the other, traversing through which, later on, dispatches the popstate event.

Did this sound confusing?

Well, it was written to be confusing. Let's ignore it for now and unravel the secrets behind pushState() and replaceState() from the very beginning.

They represent extremely easy concepts and should likewise be extremely easy to understand.

Let's begin...

First, we consider the pushState() method of the history object.

This is the simplest of all definitions.

The syntax of pushState() is shown as follows:

One extremely important thing to know is that pushState() changes the URL without ever checking whether it even actually exists or not. This is because the purpose of pushState() is not to load a webpage, but rather to just add a new entry to the history.

That's it!

Let's consider an extremely simple example.

We create a

[2]
Edit
Query
Report
Amruta Malliek
STREETCAR REPAIRER