简体   繁体   中英

Opening a popup in background

I need to open an url in a pop up window, in the background. Currently in my code, the new windows pops up on top of the current window, without going in the background. I am running my code on firefox 23.0.1-fedora 18.

I have tried using .blur() and .focus() js methods, but they are not working.

Is there a clean and reliable solution for this, which will work for firefox and chrome?

http://jsfiddle.net/6La9W/1/

html

<button >click me</button>

js

$("button").click(function(){
    var sOptions = 'target=_blank,toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1';
    var popup = window.open('http://www.stackoverflow.com','',sOptions);
    popup.blur();
});

Browsers don't allow this nowadays because peoples open illegal things in behind popup, and you shouldn't do this. but still you can do this and it is worked in IE only.

$("button").click(function(){
    var sOptions = 'target=_blank,toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1';
    var popup = window.open('http://www.stackoverflow.com','',sOptions);
    window.focus();
});

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