$(window).click(function(e) { alert('Clicked inside document'); }); $(window).blur(function(e) { alert('Clicked out of the window or on the iframe'); });