Jump to content

Recommended Posts

I have notifications that automatically update every so often, and i want it to append the amount of notifications in the page title. I have other information in the title such as site name, and page etc. How could I append the notifications to the title and keep the other information in the title.

Link to comment
https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/
Share on other sites

Yeah. I got it working, however it had some problems. Since the script that updates it runs ever 10 or so seconds, it would append (1) every 10 or so seconds. And if i replace what's in the title it wouldnt show the site name, and the page and all of that. Just everything i tried it wouldn't work right.

I know what you mean. A possible solution would be to store the title within a global var as the page loads. Then whenever you update the page title, set it to the global var + the extra string. Quick example:

 

var g_page_title;

window.onload = function() {
    g_page_title = document.title;
}

function updateTitle(title) {
    document.title = g_page_title + title;
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.