window.opener.focus() problem in FF5+

孤街浪徒 提交于 2019-11-29 11:39:15

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"

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>           
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!