问题
I'm opening new window with next code:
window.open(url,pageName1,"menubar=1,resizable=1,scrollbars=1,status=yes,width=1050,height=820");
so window is not modal
In new window I'm calling:
if (window.opener) window.opener.focus();
in IE, Chorme, FF3.6 parent window become in focus, BUT not in FF5 or FF6, how I can move focus to parent window?
回答1:
FF4+ prevernt window raising and lower by default, you can enable in options: Tools->Options->Content->Advanced... (in "Enable JavaScript" row)->Check "Raise or lower windows"
回答2:
I'm leaving here my contribution to anyone wants to open popup in background. The secret is open a blank page, then inject the desired url.
<script>
var url = 'http://example.com/page.html';
var popunder = w.open('about:blank',"window_example", "resizable=no,scrollbars=yes,height=600,width=800,status=yes,top=0,left=0");
if(window.navigator.userAgent.match(/firefox/i)){ //fix for firefox browser
popunder.document.write('<script type="text/javascript">window.opener.open("","_parent");location.replace("'+url+'");</script>');
popunder.document.close();
} else
popunder.parent.location = url;
popunder.blur();
window.focus();
</script>
来源:https://stackoverflow.com/questions/7281758/window-opener-focus-problem-in-ff5