This code is not mine and it is copied from Stack Overflow as usual.
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event)
{
history.pushState(null, document.title, location.href);
});
More detailed information about history.pushState can be seen HERE.
Here is another link for popstate.