Christian Heilmann

You are currently browsing the Christian Heilmann blog archives for February, 2022.

Archive for February, 2022

Showing different titles depending if the tab is active or not

Thursday, February 10th, 2022

I just encountered a sneaky thing I had not seen, although it probably worked in 1999 already. A web site was showing a different title on the tab, depending on it being active or not.

Different titles showing on active and inactive tab

The whole trick is to use the blur and focus event handlers on the window to change the title.

window.onblur = function() {
    document.title = 'Please come back!';
}
window.onfocus = function() {
    document.title = 'You have 6 items';
}

You could also change the Favicon that way. Maybe this is a common practice and it feels pretty spammy, but there may be some good use cases for it, too.

If you don’t want to clobber other events, it is better to use `addEventListener`:

let activeTitle = 'You have 6 items';
let inactiveTitle = 'Please come back';
document.title = activeTitle;
window.addEventListener('blur', e => {
    document.title = inactiveTitle;
});
window.addEventListener('focus', e => {
    document.title = activeTitle;
});

Sending email notifications from GitHub organisations to different emails

Tuesday, February 1st, 2022

I’m part of a few organisations on GitHub and had one email address for notifications. This annoyed me as I didn’t want company notifications to my personal account as I couldn’t answer these. As it turns out, you can set up several email addresses in your GitHub account. In settings, go to Access > Emails and you can add more than one address.

The GitHub settings screen showing my emails and allowing me to add more

If you then go to the `Notifications` settings of GitHub and scroll all the way down to `Custom Routing`, you can define which organisation should send notifications to which email account.

The Custom Routing screen of Github

Thanks to my colleague Anton Ross for showing me this!