OCTOBER 07, 2010

Google Chrome bug when setting document.title after tab switching

TAGS: javascript, jquery,

Usually it's IE6 that makes you cry because of quirky behavior, but today I ran into a bug in Chrome. It caused notification messages to sometimes get stuck in the title bar, in my Title Alert jQuery plugin.

It turns out that if you set document.title immediately after you have activated the browser tab (for example in the window.onfocus event handler), the title change will not be visible in the tab bar or task bar.

One can easily reproduce this by opening any web page in Chrome, bringing down the JavaScript console, and entering the following code:

window.onfocus = function(){document.title = "hello world";};

When switching to another tab and back again after this code has been executed, the text in the tab bar and task bar doesn't change, but using the JavaScript console you can see that the document.title has in fact changed.

The bug does not appear if you, instead of switching between tabs, switches to another application and back again.

New version of Title Alert

I've released a new version (0.7) of my jQuery plugin Title Alert that includes a workaround for this problem. It also contains a new option parameter (stopOnMouseMove) and an IE6 fix.

Download it here or visit the GitHub page.

ABOUT ME

Jonatan Heyman My name is Jonatan Heyman, and I'm a programmer. On this blog I write about programming, the web and technology. I also listen to a large number of indie pop tunes. You can read more about me on the about page.

TAGS

MY LATEST TWEETS

Copyright (c) 2009-2010 Jonatan Heyman