I haven't tested this in other browsers, but it seems to work in Webkit. I'll let you try IE. :o)
Try it out: http://jsfiddle.net/ScKbk/
After you click to start the interval, change the focus of the browser window to see the result change. Again, tested only in Webkit.
var window_focus;
$(window).focus(function() {
window_focus = true;
}).blur(function() {
window_focus = false;
});
$(document).one('click', function() {
setInterval(function() {
$('body').append('has focus? ' + window_focus + '<br>');
}, 1000);
});