How to get the history value.pushState?

it is written that the method of history.the pushState(data,title,url) adds an entry to the history stack of the session.
Takes three parameters:
  • data — the data record in the stack history. These data can be used in the handler for the popstate event. If no additional data transfer is not required, specify null.
  • title — the title of the page, you can specify null.
  • url — the url can be relative or absolute.


I so understood that is necessary to pass so {var: value}
and how to read them? please explain...
the popstate event handler
window.addEventListener("popstate", function(e) {
 getContent(location.pathname, false);
});

March 19th 20 at 08:41
3 answers
March 19th 20 at 08:43
Solution
document.addEventListener('click', () => {
 var state = { 'the primary objective of BCC': 1, 'user_id': 5 };
 history.pushState(state, null, location.pathname)
})

window.addEventListener('popstate', e => { /* event is triggered when you press the buttons "back" and "forward" in the browser */
 console.log(e.state); /* in the method state is an object state = { 'the primary objective of BCC': 1, 'user_id': 5 } */
})
thank you, and the various pundits current links to throw can - hertha34 commented on March 19th 20 at 08:46
March 19th 20 at 08:45
March 19th 20 at 08:47
(function()
{
 var tabMenu = document.getElementById('tabMenu');

 for(var tM = 0; tM < tabMenu.children.length; tM++)
{
 tabMenu.children[tM].children[0].onclick = function()
{
 history.pushState(null, null, this.href);

 ajax('POST', '/app/controllers/route.php', 'controller=' + location.pathname);

 return false;
}
}

 function ajax(method, puth, param)
{
 var xhr = new XMLHttpRequest();

 xhr.open(method, puth, true);
 xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

 xhr.onreadystatechange = function()
{
 if(xhr.readyState === 4)
{
 if(xhr.status === 200)
{
 var fh5comain = document.getElementById('fh5co-main');

 fh5comain.innerHTML = xhr.responseText;
}
}
}

xhr.send(param);
}

 window.onpopstate = function()
{
 ajax('POST', '/app/controllers/route.php', 'controller=' + location.pathname);
}

}());

Find more questions by tags JavaScript