简体   繁体   中英

window.opener.focus() problem in FF5+

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?

FF4 +优先窗口默认升高和降低,您可以在以下选项中启用:工具->选项->内容->高级...(在“启用JavaScript”行中)->选中“升高或降低窗口”

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>           

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM