I just recently saw this on two different websites, does anyone know how it is done? If you have multiple tabs open, and you leave the current one, the title in the tab is changed. Very nice trick!
http://blog.invisionapp.com/
http://zerosixthree.se/create-a-responsive-header-video-with-graceful-degradation/
The <title> tag defines the title of the document. The title must be text-only, and it is shown in the browser's title bar or in the page's tab. The <title> tag is required in HTML documents! The contents of a page title is very important for search engine optimization (SEO)!
The <title> element: defines a title in the browser toolbar. provides a title for the page when it is added to favorites. displays a title for the page in search-engine results.
This is a great way to optimize your title with keywords. The page title format applies to all pages except your homepage and collection items. By default, the page title format is Page Title — Site Name, using the variables %p and %s. %p pulls in the SEO title for that page.
To have the title of the page, product, or blog post be the first words in a browser tab or search results link, place the page SEO title ( %p) or item SEO title ( %i) at the beginning of the title format. This places more importance on the content of the page rather than the entire site.
This works by registering Handlers on the onfocus
and onblur
events of window
.
jQuery-Style:
$(window).on('blur', function() { ... });
Without jQuery:
window.onblur = function() { ... }
If that was not clear: the pages title can be read/written via document.title
$(function() {
var message = "Don't forget us";
var original;
$(window).focus(function() {
if (original) {
document.title = original;
}
}).blur(function() {
var title = $('title').text();
if (title != message) {
original = title;
}
document.title = message;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With