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.