Window.focus document.focus and blur events
From Code Trash
if (/*@cc_on!@*/false) { // check for Internet Explorer document.onfocus = focs; } else { window.onfocus = focs; } function focs() { var aye = getCookie('shippingaddress') if(aye) { requestx('',baseurl+'products/get_addressbooks/',function(jax,so){ if(so.status)document.getElementById('').innerHTML = so.content setCookie('shippingaddress',0,10); }) } }
The following is copied from the following site.
http://www.thefutureoftheweb.com/demo/2007-05-16-detect-browser-window-focus/
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript">
function onBlur() { document.body.className = 'blurred'; }; function onFocus(){ document.body.className = 'focused'; }; if (/*@cc_on!@*/false) { // check for Internet Explorer document.onfocusin = onFocus; document.onfocusout = onBlur; } else { window.onfocus = onFocus; window.onblur = onBlur; }
</script> <style type="text/css"> .focused #focused, .blurred #blurred { display: inline } .focused #blurred, .blurred #focused { display: none } .focused { background: white; color: black; } .blurred { background: black; color: white; } </style> </head> <body class="focused"> <h1>window.onfocus() and window.onblur() demo</h1> <p>Switch to a different program to blur this page.</p> <p>You can also just click into the location bar (except in Safari).</p> <p>Click this page again to focus it.</p> <p>When blurred, this page will have a black background with white text.</p> <p>The window is currently <span id="focused">FOCUSED</span><span id="blurred">BLURRED</span>. <p><a href="http://www.thefutureoftheweb.com/blog/detect-browser-window-focus">Click here for a discussion of this demo.</a></p> <p id="log"></p> <input> </body> </html>