最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to open popup windows in background using javascript? - Stack Overflow

programmeradmin0浏览0评论

Is it possible to open pop-up windows BEHIND the current active screen using java script?

 var win= window.open(value,'_blank');

the above script opens pop windows in browser tab but I loss active page from my sight.

any suggestion?

Thanks in advance

Solution:

As per @Brian advised,

var win=window.open(value,null,"height=400,width=600,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
win.blur();

Its works in IE,FireFox and safari but not in Chrome browser.

Can any one suggest how to open multiple popup boxes in IE browser? The above script will open only one pop up in IE.

Is it possible to open pop-up windows BEHIND the current active screen using java script?

 var win= window.open(value,'_blank');

the above script opens pop windows in browser tab but I loss active page from my sight.

any suggestion?

Thanks in advance

Solution:

As per @Brian advised,

var win=window.open(value,null,"height=400,width=600,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
win.blur();

Its works in IE,FireFox and safari but not in Chrome browser.

Can any one suggest how to open multiple popup boxes in IE browser? The above script will open only one pop up in IE.

Share Improve this question edited Aug 8, 2011 at 13:05 prabu asked Jul 27, 2011 at 10:31 prabuprabu 6,1718 gold badges36 silver badges39 bronze badges 1
  • 4 sounds shady .. what is this for ? – Gabriele Petrioli Commented Jul 27, 2011 at 10:36
Add a comment  | 

4 Answers 4

Reset to default 8

You can add:

win.blur();

... to your code ...

Or

this.window.focus();

+1 to Brian's answer to refocus the original window afterwards. If you, for some reason, always want it to be behind, you can use the alwaysLowered property:

alwaysLowered
If set to yes, the new created window floats below, under its own parent when the parent window is not minimized. alwaysLowered windows are often referred as pop-under windows. The alwaysLowered window can not be on top of the parent but the parent window can be minimized. In NS 6.x, the alwaysLowered window has no minimize system command icon and no restore/maximize system command.

Good documentation of all the available features can be found on the MDC window.open page.

I found that with Firefox it was not possible to push the window to the back, no matter how much of the code I modified. Ultimately I settled for making the window small enough 10, 10 so that it appeared in one of the corners and was barely perceived by the visitor.

var win=window.open(value,null,"height=10,width=10,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");

Chrome opens the popup/under in a tab and iE does place it in the background, behind the active window.

For more cross-browser solution I'd suggest to take a look at this script — jquery-popunder:

...was tested with:

  • Mozilla Firefox 3-19
  • Google Chrome 10-25
    • Note: Currently you can only create 2 popunder in Chrome 22-24
    • Note: In Chrome 23-24 you'll need a separate event for the popunder-effect (see the examples!)
  • Microsoft Internet Explorer 6-9
  • Apple Safari 5

    Known issues:

  • the script does not work with the Opera-Browser, so the opera-browser is disable by default
  • the script does not work in Firefox under Gnome
  • in Firefox, when the setting: 'Open new windows in a new tab instead' is deactivated

Note that

This script will only work, if the popunder is opened on a user-generated event (e.g. click or submit).

发布评论

评论列表(0)

  1. 暂无评论