I’ve used:
var win = window.open('http://www.google.co.uk','foo');
to open a new window I’ve then navigated back to the orginal window leaving the new window open and used:
win.focus();
I expected the browser to switch back to the foo window how ever IE9 ignores it and stays on the current window. Works in chrome and IE6 I’m assuming this may have been disabled as a security risk. Is there a way to enable window.focus in IE9 via security settings or registry settings?
This is my full code:
<a onclick="OpenWindow();">Click here to open a window</a><br />
<a onclick="SelectWindow();">click here to switch to window</a>
<script language="javascript" type="text/javascript">
var win;
function OpenWindow() {
win = window.open("http://www.google.co.uk", "foo");
}
function SelectWindow() {
win.focus();
}
</script>
It is a known bug in Internet Explorer 9. Check out the article, A web page may fail to get focus in Windows Internet Explorer 9 for more info.
Registry Fix