Search code examples
html5-history

Page title is not changed by history.pushState


I've just opened a blank HTML page with some little amount of base tags (like html, body, head, etc) in Google Chrome, and tried to execute the following command in console:

history.pushState(null, 'my test title', '/test/url');

History events work fine, but the page title stays unchanged. Is it OK? Should I change it manually every time? If I should, why there is such parameter in pushState() method like title?


Solution

  • It seems current browsers don't support pushState title attribute. You can easily achieve the same thing by setting it in JS.

    document.title = "This is the new page title.";