The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Update title of dynamically-loaded page?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #237523

    In the article/code at, what mods would be required to also update the page title (currently it remains that of the original-load page, and thus all history entries confusingly have that title too).

    I apologize for asking such an open question, but I simply don’t have the brainpower to understand much of this stuff.

    Please, thanks, etcetera.


    If you try to change this title of page and don’t get success, try this and i think what you will be happy =)

    title = document.getElementsByTagName(‘title’)[0].innerHTML = prefix + ‘Deleting row(s)’;

    window.history.replaceState(null, title, destination);



    Unfortunately, it doesn’t appear to update the title.

    Having searched a lot on this issue… it seems that a downside of using Ajax to load new content the title remains that of the first page, not the subsequent page.

    Apparently, jQuery Mobile has a fix ( and automatically parses the title of the page pulled via Ajax and changes the title attribute of the parent document to match… but I don’t know how to use it


    Why wouldn’t it update the url? There’s a line for that :

    history.pushState(null, null, _href);

    You don’t really need Modernizr, this’ll do the same :

    if (history.pushState !== 'undefined')

    Did you add that plugin to begin with by the way?

    The page was written a while back, at this point it would be better to use .on() everywhere instead of .delegate() and such…


    Why wouldn’t it update the url? There’s a line for that…

    I don’t know – this stuff is beyond my understanding.
    Perhaps I misunderstood how to add it… which I did as a separate script rather than add to the original.

    And as regards the need for Modernizr and ‘delegate’ etc… again, I simply don’t know enough.

    I’m looking for – and appreciate of – any help I can get to obtain code which will enable me to dynamically refresh part of a page and update the title appropriately.

    If I could find a script to buy, I’d do so.


    Modernizr is a separate plugin that you’d need to add for the code to work, otherwise that line should be replaced with the one I mentioned.

    if (Modernizr.history)
    if (history.pushState !== 'undefined')

    Should work for the rest. A live example of your efforts would otherwise be needed at this point to do any debugging…

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.