简体   繁体   中英

window.open(url, target) doesn't activate a tab in Firefox

This simple code:

<button onclick="window.open('https://google.com', 'my-tab')">open google</button>

Works fine in Chrome, but in Firefox (latest v75) it opens always, but activates a new tab only the first time.

Live demo: https://jsfiddle.net/nmp049Lu/1/

Steps to reproduce

  1. click the button, a new tab with google in it should be opened and active
  2. do not close the newly opened tab, but go back to the live demo tab
  3. click the button again

Expected behavior

The same tab as in step 2 gets opened and activated (gets visible)

Actual behavior

The same tab as in step 2 gets opened but not activated (doesn't get visible)

Is this a bug in Firefox or I'm missing something?

Here try this:

<button onclick="window.open('https://google.com', 'my-tab').focus()">open google</button>

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