FF5 中的 window.opener.focus() 问题+

发布于 2024-12-02 18:21:03 字数 305 浏览 5 评论 0原文

我正在使用下一个代码打开新窗口: window.open(url,pageName1,"menubar=1,ressized=1,scrollbars=1,status=yes,width=1050,height=820");

不是模态的

所以窗口在新窗口中 我正在调用:

if (window.opener) window.opener.focus();

在 IE、Chorme、FF3.6 父窗口中成为焦点,但不是在 FF5 或 FF6 中,如何将焦点移动到父窗口?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

箹锭⒈辈孓 2024-12-09 18:21:03

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

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"

梦里梦着梦中梦 2024-12-09 18:21:03

我将在这里留下我对任何想要在后台打开弹出窗口的人的贡献。秘诀是打开一个空白页面,然后注入所需的网址。

<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>           

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>           
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文