How can I update the bookmark title in the same way that GMail / Facebook does?

Each time you receive a new email or something happens on your Facebook profile, the name of your browser changes. For example, in gmail, if you receive a new email, it will change to something like GMail (1). How can I get the same effect in my application? I think this is Javascript, but I'm not sure.

+5
source share
2 answers

This should be as simple as changing the property document.titleto JavaScript:

document.title = "New title (1) new message";
+11
source

can be done using jQuery (Javascript library)

This sample will change the page name 2 seconds after the document is fully loaded.

function changeTitle(new_value){
    $("title").val(new_value);  //this line changes value of <title> element
    //pure javascript:  document.title = new_value;
}

$(document).ready(function(){
    setTimeout('changeTitle("New Title")',2000); //calls function changeTitle() after 2secs
});
+2

All Articles