I have a problem with Javascript window focus setting. I've written a function to open a new window with the JS method window.open() and save the return value to a variable. Now I have a link on the first page and by clicking on this link the second, with window.open() opened, window should get the focus. But this won't work. Is there any way to get this working?
My code looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<script type="text/javascript" language="JavaScript">
var myWindow;
function checkForRefresh() {
myWindow = window.open("test.html", "TestMain");
myWindow.focus();
}
function switchFocus(umsWindow) {
myWindow.focus();
}
</script>
</head>
<body onLoad="checkForRefresh()">
<p><a href="javascript:switchFocus();">Test Link</a></p>
</body>
</html>