Open new window in javascript without focus

Asked

Viewed 49 times

-1

I’m trying to open a new window without losing the focus of the main but it doesn’t work:

function openUrl() {
  window.open(url);
  window.focus();
}

1 answer

0

(Translation) Original response here

What you are looking for is called "pop-under window"

  • Open a new window using var handle = window.open()
  • Lose focus of new window using handle.blur()
  • The return focus to your existing window using window.focus()

However, it is not a guarantee, as the user’s browser settings can override this behavior, especially pop-up blockers.


I did local tests, and really going to have a big problem with pop-up blocker, my suggestion is to open tabs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.