shortysbest Posted December 12, 2010 Share Posted December 12, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/ Share on other sites More sharing options...
Adam Posted December 12, 2010 Share Posted December 12, 2010 Yeah, just modify the document.title property. Quote Link to comment https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/#findComment-1146363 Share on other sites More sharing options...
shortysbest Posted December 12, 2010 Author Share Posted December 12, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/#findComment-1146365 Share on other sites More sharing options...
Adam Posted December 12, 2010 Share Posted December 12, 2010 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; } Quote Link to comment https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/#findComment-1146373 Share on other sites More sharing options...
shortysbest Posted December 12, 2010 Author Share Posted December 12, 2010 Yeah i had done that too, had an issue, but I believe i know the fix. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/221418-can-you-append-things-to-page-title/#findComment-1146385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.