I'm trying to use the focus() function to focus on a parent window after clicking on a link that runs a function. The code I have works in IE, but it doesn't work in Chrome for some reason.
Here is the HTML with the function (moveToNext(var1,var2)):
<td style="border-left: solid 1px #000000;border-bottom: solid 1px #000000;" nowrap="">
<a href="javascript:moveToNext('xxxxxxxxxxxx','null')">xxxxxxxxxxxx</a>
</td>
Here is the code in the function:
function moveToNext(var1,var2){
...
// Other code to set form.action
...
window.opener.document.forms[0].submit();
window.opener.document.getElementById('elementid').focus();
return;
}
I also saw this question, document.getElementById(id).focus() is not working for firefox or chrome, but this didn't work for me below:
window.opener.document.forms[0].submit();
window.setTimeout(function() {
window.opener.document.getElementById('elementid').focus();
}, 0);
The function is working in Chrome because the form is being submitted, the focus() just isn't working.
Anybody know how to fix this or have any suggestions?