Okay, here’s one I’m trying to solve without much success to date….
I have a web page which contains a couple different ActiveX controls running in Internet Explorer (let’s assume its version 6). One of those controls is a terminal emulator that has a green screen session to a mainframe.
All is well, the user can access the page, the terminal emulator loads, telnets them to the mainframe, even logs them in and brings them to a pre-determined place in the mainframe app automatically using some macros we built in and so on.
The problem arises when the user alt-tabs to another browser window or to another application altogether. When they alt-tab *back
This is more in the “annoying” category (imagine someone who uses this thing all day long), and I’m looking for a way to make the control get focus as soon as the browser window gains focus from the OS. This sounds like it should be straightforward, but in fact it isn’t.
First thing I tried was putting something in the BODY onFocus event, but this event does not seem to fire when the browser window regains focus. Next thing I tried doing is creating a simple function and assigning this to the window.onfocus event, and no joy here either. Essentially, here’s what I’ve been trying (scaled down for simplicity):
[CODE]<script type=”text/javascript”>
var objLogon ;
var objTelnet ;
function init()
{
objLogon = window.document.frmLogon ; // set global form ref
// do some stuff, set the objTelnet reference and log user in, etc..
window.onfocus = setTerminalFocus() ; // set onfocus event handler
objLogon.hdnLoaded.value = 1 ; // set form loaded flag
}
function setTerminalFocus()
{
if( window.document.frmLogon.hdnLoaded.value == 1 ) {
objTelnet.focus() ;
}
}
</script>
<body onLoad=”javascript:init();”>
<form name=”frmLogon”>
<input type=”hidden” name=”hdnLoaded” value=”0″>
…
The solution for this may well be simple and I’m just missing it, but if you know a way to solve this problem then please let me know!
Cheers,
Fidel