Reputation: 63748
I'm using this technique to detect when the current tab gains focus and this one to set focus on the <applet>
, however I get a couple of errors since the applet isn't ready when the first onFocus occurs during page-load. It doesn't appear to stop anything working but errors are not ideal!
In a perfect world I'd only set the focus handlers once the applet is ready. Alternatively the focus handler would check the applet is valid before 'touching' it... either is fine depending on which is simpler. Non-jQuery answers preferred please!
My HTML looks like:
<head>
<script language="javascript">
function focusIn()
{
document.myApplet.requestFocus();
}
if ("onfocusin" in document)
document.onfocusin = focusIn;
else
window.onfocus= focusIn;
</script>
</head>
Upvotes: 1
Views: 707
Reputation: 168825
At the end of the Applet.start()
method, call a JS function to indicate 'applet is ready'. The applet might even be able to detect a tab change to the applet page or the browser being restored from minimized.
Upvotes: 1