Every time you receive a new 开发者_如何学Cemail, or something happens on your Facebook profile, your browser tab's name changes. For example, on gmail, if you receive a new mail, it will change to something like GMail (1)
. How can I get the same effect in my application? I think it's a Javascript thing, but I'm not sure.
This should be as simple as modifying the document.title
property with JavaScript:
document.title = "New title (1) new message";
can be done using jQuery (Javascript library)
This sample will change title of page 2 seconds after document fully loads
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
});
精彩评论