Is there a way of checking the window's focus (not the document) from Javascript?

I see numerous questions along these lines, but they all require checking the document object. I’m trying to do this from a cross-domain iframe, so I don’t have access to top.document. Any way to do with with the object?

UPDATE: see my answer below

  • Cross-domain connection in Socket.IO
  • What can cause location.href to be undefined?
  • Can I make a jQuery JSONP request without adding the '?callback=' parameter in URL?
  • Why does an XMLHttpRequest include an Origin header?
  • Using Ajax with Cookies
  • Canvas tainted by cross-origin data
  • How to get data with JavaScript from another server?
  • Header can't pass in ajax using cross domain
  • Iframe Cross domain communication - resize event - cross browser?
  • How do I send a cross-domain POST request via JavaScript?
  • Reading parent document from iFrame and changing parent
  • How to create callback for form submit event (without ajax)
  • 2 Solutions collect form web for “Is there a way of checking the window's focus (not the document) from Javascript?”

    Pretty sure the answer is no. Such things are the responsibility of the document and not the window.

    I found this answer in another question, which uses window.onfocus and window.onblur. Unfortunately browser security seems to prevent attaching events to….