var initTabTitle = function() {
/* Tab Focus Message */
/********************************************************/
var $doc = $(document),
$body = $("body"),
$window = $(window);
var titleTimer = 0;
var titleTimerRunning = false;
var origTitle = $doc.find("title").text();
var newTitle = "Don't forget to read this...";
var isOrig = true;
function swapTitle(){
isOrig = ! isOrig;
var t = isOrig ? origTitle : newTitle;
setTitle( t );
}
function setTitle( t ){
document.title = t;
}
$window
.on("focus", function(){
setTitle( origTitle );
// ugly hack because of a bug in Chrome which causes a change of
// document.title immediately after tab switch
// to have no effect on the browser title
setTimeout(function() {
setTitle( '.' );
setTitle( origTitle );
}, 1000);
})
.on("blur", function(){
setTitle( newTitle );
});
};
$(document).ready(function(){
initTabTitle();
});
This is good for Bloggers that wanted to leave a message to your audience whenever they switched tab out from your Articles.
Copyright to InVision Team
Copyright to InVision Team
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.