My page should make notification sounds only when the window is in the background.  I can track the window.onfocus and window.onblur events to notice when the focus state changes.  However, I don't know whether the window will load focused or not, since it might load in a background tab, for instance.
How do I decide whether to play sounds or not before I get an onfocus/onblur event?