okno onfocus

window.onload = function() { 
    window.onfocus = function() { alert('example'); };
};
Ashamed Aardvark