Has Focus ?
<html> <body> <button onclick="alert(document.hasFocus());">document.hasFocus()</button> </body> </html>