What is history.pushState method in JavaScript

history.pushState() is a method introduced in HTML5 which is used to add parameters in page url without reloading the page. It takes 3 parameters: a state object, a title (it is currently ignored) and  a Url.

Here is some brief description of each parameters-

state object:

Its a JavaScript object associated with the new history event created by pushState() This object can be anything which can be serialized. Browser has a size limit of 640k characters which can be saved as state object.


This parameter is currently ignored as some of the browsers as of now does not support this. You can pass a blank string at the place of this parameter.


The new URL is given in this parameter. Passing URL in this parameter won’t be reloaded by browser and even browser will not check for this URL’s existence.

Note that the new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception.

Learn more about pushState()method.

Leave a Reply

Your email address will not be published. Required fields are marked *