I have such situation. I try to open a window with window.open
function new window was opened in a front of main window, how can i open it in background of main window, without focus on new. Is it possible to do such thing?
Asked
Active
Viewed 7.0k times
38

bcmcfc
- 25,966
- 29
- 109
- 181

Anton Sementsov
- 1,196
- 6
- 18
- 34
3 Answers
26
What you seek is called a "pop-under" window
- Open a new window using
let handle = window.open()
- Lose focus of the new window by using
handle.blur()
- The return focus to your existing window using
window.focus()
Example:
var handle = window.open('https://stackoverflow.com/');
handle.blur();
window.focus();
However, it's not a guarantee as user browser settings may override this behavior, especially pop-up blockers.
-
1Does not work with Chrome v108. – Avatar Jan 10 '23 at 07:05
-4
No you cant open window behind the main window. if you are using window.open()
then it will be top of the main window. that's how the pop up windows works.
alternatively you can do this
Window.open();
yourMainWindow.focus();

Ravi Gadag
- 15,735
- 5
- 57
- 83
-
Ok, maybe there are some other ways to open new window in background, without `window.open()` function – Anton Sementsov Feb 28 '13 at 10:59
-
@AntonSementsov What are the other ways to do the same through js. – Sanjay Goswami Jan 15 '16 at 13:41