Skip to content

Instantly share code, notes, and snippets.

@mcnaveen
Last active January 29, 2019 06:38
Show Gist options
  • Save mcnaveen/4a2c5e7ed2417811896d7709c64af45f to your computer and use it in GitHub Desktop.
Save mcnaveen/4a2c5e7ed2417811896d7709c64af45f to your computer and use it in GitHub Desktop.
Change Title Bar text, When switching to Other Tab
== Place the Below code, Above the </head> Tag. ===
== For WordPress, Use the Plugin. " https://wordpress.org/plugins/code-snippets/ ==
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
$(function () {
var message = "Hey, come back!";
var original;
$(window).focus(function() {
if(original) {
document.title = original;
}
}).blur(function() {
var title = $('title').text();
if(title != message) {
original = title;
}
document.title = message;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment