I’m looking to rotate a web page document title using JS. So for example:
Change to Domain.com to New Messgae - Domain.com and then back to Domain.com and so on, very similar to how Facebook does it with the new messages when using chat.
I have looked into using SetInterval but it only excepts one expression? Is it possible to change this or is using SetInterval the wrong function to use?
$(document).ready(function () {
setInterval(function () {
$(document).attr('title', 'New Message — Domain.com');
},
2000);
});
Right now, you keep setting the same new title every 2 seconds, i.e. you won’t see a change after the first change. You need to store the old title and alternate between two states, displaying the old and new titles: